Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions infrastructure/terraform/components/notifyai/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ resource "aws_lambda_function" "bedrock-messager" {
env_logging_s3_key_prefix = local.s3_lambda_logging_key
env_guardrail_arn = aws_bedrock_guardrail.notifai-bedrock-guardrail.guardrail_arn
env_guardrail_version = "DRAFT"
env_logging_s3_account_id = var.aws_account_id
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/backend/bedrock-prompt-messager/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ def __init__(self):
self.logging_s3_key_prefix = os.environ.get("env_logging_s3_key_prefix")
self.guardrail = os.environ.get("env_guardrail_arn")
self.guardrail_version = os.environ.get("env_guardrail_version")
self.logging_s3_account_id = os.environ.get("env_logging_s3_account_id")
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _get_admail_tool_config(self):
def log_prompt_details_to_s3(
self, promptinput, promptoutput, guardrail_assessment, filename
):
if not self.config.logging_s3_bucket or not self.config.logging_s3_key_prefix:
if not self.config.logging_s3_bucket or not self.config.logging_s3_key_prefix or not self.config.logging_s3_account_id:
print(constants.ERROR_S3_LOGGING_NOT_CONFIGURED)
return

Expand Down Expand Up @@ -164,6 +164,7 @@ def log_prompt_details_to_s3(
Key=s3_key,
Body=json.dumps(log_data, indent=4),
ContentType="application/json",
ExpectedBucketOwner=self.config.logging_s3_account_id,
)
except Exception as e:
print(f"Error logging to S3: {e}")
1 change: 1 addition & 0 deletions src/backend/bedrock-prompt-messager/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ def set_env_vars(monkeypatch):
monkeypatch.setenv("env_logging_s3_key_prefix", "logs/")
monkeypatch.setenv("env_guardrail_arn", "test-arn")
monkeypatch.setenv("env_guardrail_version", "1")
monkeypatch.setenv("env_logging_s3_account_id", "123456789012")
Loading