Skip to content

Commit fde341e

Browse files
committed
eli-384 adding policy to allow put logs
1 parent 4d3e02b commit fde341e

File tree

1 file changed

+22
-0
lines changed
  • infrastructure/stacks/api-layer

1 file changed

+22
-0
lines changed

infrastructure/stacks/api-layer/waf.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,28 @@ resource "aws_cloudwatch_log_group" "waf" {
188188
]
189189
}
190190

191+
# CloudWatch Logs resource policy to allow WAF to write logs
192+
resource "aws_cloudwatch_log_resource_policy" "waf" {
193+
count = local.waf_enabled ? 1 : 0
194+
policy_name = "${local.workspace}-waf-logging-policy"
195+
policy_document = jsonencode({
196+
Version = "2012-10-17"
197+
Statement = [
198+
{
199+
Effect = "Allow"
200+
Principal = {
201+
Service = "delivery.logs.amazonaws.com"
202+
}
203+
Action = [
204+
"logs:CreateLogStream",
205+
"logs:PutLogEvents"
206+
]
207+
Resource = "${aws_cloudwatch_log_group.waf[0].arn}:*"
208+
}
209+
]
210+
})
211+
}
212+
191213
# KMS Key for WAF logs encryption
192214
resource "aws_kms_key" "waf_logs" {
193215
count = local.waf_enabled ? 1 : 0

0 commit comments

Comments
 (0)