Skip to content

Commit

Permalink
Merge pull request #184 from USSBA/IA-3420
Browse files Browse the repository at this point in the history
IA-3420: Updated ECS task policy to include permissions to write logs…
  • Loading branch information
yaythecloud authored Dec 11, 2023
2 parents 759c336 + 52bf410 commit 4400174
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
29 changes: 17 additions & 12 deletions terraform/fargate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module "api" {

## If the ecs task needs to access AWS API for any reason, grant
## it permissions with this parameter and the policy resource below
#task_policy_json = data.aws_iam_policy_document.fargate.json
task_policy_json = data.aws_iam_policy_document.fargate.json

# Deployment
enable_deployment_rollbacks = true
Expand Down Expand Up @@ -82,14 +82,19 @@ module "api" {
}

## If the ecs task needs to access AWS API for any reason, grant it permissions with this
#
#data "aws_iam_policy_document" "fargate" {
# statement {
# sid = "AllResources"
# actions = [
# "s3:ListAllMyBuckets",
# "s3:GetBucketLocation",
# ]
# resources = ["*"]
# }
#}

data "aws_iam_policy_document" "fargate" {
statement {
sid = "AllResources"
actions = [
"s3:GetObject",
"s3:PutObject",
"s3:List*",
"s3:GetBucketLocation",
]
resources = [
"${data.aws_s3_bucket.logs.arn}",
"${data.aws_s3_bucket.logs.arn}/*"
]
}
}
4 changes: 4 additions & 0 deletions terraform/infrastructure-resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ data "aws_sns_topic" "alerts" {
for_each = toset(["green", "yellow", "red", "security"])
name = "${local.account_name}-teams-${each.value}-notifications"
}

data "aws_s3_bucket" "logs" {
bucket = "${local.account_ids[terraform.workspace]}-${local.region}-logs"
}

0 comments on commit 4400174

Please sign in to comment.