Skip to content

Commit 4c79315

Browse files
committed
Allow authorizer lambda to log
1 parent d184791 commit 4c79315

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

infrastructure/terraform/components/api/module_authorizer_lambda.tf

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module "authorizer_lambda" {
3131
log_destination_arn = local.destination_arn
3232
log_subscription_role_arn = local.acct.log_subscription_role_arn
3333

34+
depends_on = [aws_cloudwatch_log_group.api_gateway_execution]
35+
3436
lambda_env_vars = {
3537
CLOUDWATCH_NAMESPACE = "/aws/api-gateway/supplier/alarms",
3638
CLIENT_CERTIFICATE_EXPIRATION_ALERT_DAYS = 14,
@@ -39,7 +41,7 @@ module "authorizer_lambda" {
3941
}
4042
}
4143

42-
data "aws_iam_policy_document" "authorizer_lambda" {
44+
data "aws_iam_policy_document" "authorizer_lambda_iam" {
4345
statement {
4446
sid = "AllowPutMetricData"
4547
effect = "Allow"
@@ -53,3 +55,25 @@ data "aws_iam_policy_document" "authorizer_lambda" {
5355
]
5456
}
5557
}
58+
59+
resource "aws_iam_policy" "authorizer_lambda_logging_policy" {
60+
name = "function-logging-policy"
61+
policy = jsonencode({
62+
"Version" : "2012-10-17",
63+
"Statement" : [
64+
{
65+
Action : [
66+
"logs:CreateLogStream",
67+
"logs:PutLogEvents"
68+
],
69+
Effect : "Allow",
70+
Resource : "arn:aws:logs:*:*:*"
71+
}
72+
]
73+
})
74+
75+
resource "aws_iam_role_policy_attachment" "authorizer_lambda_logging_policy_attachment" {
76+
role = aws_iam_role.authorizer_lambda_iam.id
77+
policy_arn = aws_iam_policy.authorizer_lambda_logging_policy
78+
}
79+
}

0 commit comments

Comments
 (0)