Skip to content

Commit

Permalink
Wardship: Delete log configuration from ECS, add TrustEventsToStoreLo…
Browse files Browse the repository at this point in the history
…gEvents policy (#3698)
  • Loading branch information
matt-k1998 authored and mitchdawson1982 committed Oct 17, 2023
1 parent fcd7894 commit 11a6f98
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions terraform/environments/wardship/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "aws_ecs_cluster" "wardship_cluster" {

resource "aws_cloudwatch_log_group" "deployment_logs" {
name = "/aws/events/deploymentLogs"
retention_in_days = "7"
}

resource "aws_ecs_task_definition" "wardship_task_definition" {
Expand All @@ -32,14 +33,6 @@ resource "aws_ecs_task_definition" "wardship_task_definition" {
hostPort = 80
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = "${aws_cloudwatch_log_group.deployment_logs.name}"
awslogs-region = "eu-west-2"
awslogs-stream-prefix = "ecs"
}
}
environment = [
{
name = "RDS_HOSTNAME"
Expand Down Expand Up @@ -262,3 +255,24 @@ resource "aws_cloudwatch_event_target" "logs" {
target_id = "send-to-cloudwatch"
arn = aws_cloudwatch_log_group.deployment_logs.arn
}

resource "aws_cloudwatch_log_resource_policy" "ecs_logging_policy" {
policy_document = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "TrustEventsToStoreLogEvent",
"Effect": "Allow",
"Principal": {
"Service": ["events.amazonaws.com", "delivery.logs.amazonaws.com"]
},
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:eu-west-2:${data.aws_caller_identity.current.account_id}:log-group:/aws/events/*:*"
}
]
})
policy_name = "TrustEventsToStoreLogEvents"
}

0 comments on commit 11a6f98

Please sign in to comment.