Skip to content

Commit 61865da

Browse files
authored
Merge pull request #66 from DNXLabs/fix/remove-cw-ecs-policu
Add cw events log policy for all services on cluster
2 parents 5252479 + ccf0473 commit 61865da

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

_data.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
data "aws_region" "current" {}
2+
3+
data "aws_partition" "current" {}
4+
25
data "aws_ami" "amzn" {
36
most_recent = true
47
owners = ["amazon"]

cloudwatch-events-policy.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
data "aws_iam_policy_document" "ecs_events" {
2+
statement {
3+
actions = [
4+
"logs:CreateLogStream",
5+
"logs:PutLogEvents",
6+
"logs:PutLogEventsBatch",
7+
]
8+
9+
resources = ["arn:aws:logs:${data.aws_region.current.name}:${data.aws_partition.current.partition}:log-group:/ecs/events/${var.name}/*"]
10+
11+
principals {
12+
identifiers = ["events.amazonaws.com", "delivery.logs.amazonaws.com"]
13+
type = "Service"
14+
}
15+
}
16+
}
17+
18+
resource "aws_cloudwatch_log_resource_policy" "ecs_events" {
19+
policy_document = data.aws_iam_policy_document.ecs_events[0].json
20+
policy_name = "capture-ecs-events-${var.name}"
21+
}

0 commit comments

Comments
 (0)