Skip to content

Commit

Permalink
Merge pull request #251 from binbashar/feature/source_account
Browse files Browse the repository at this point in the history
Feature/source account
  • Loading branch information
esacteksab authored Nov 9, 2022
2 parents 69f17ad + 279a908 commit 6d7fbb1
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -229,26 +229,33 @@ data "aws_iam_policy_document" "main" {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
actions = ["s3:GetBucketAcl"]
actions = ["s3:GetBucketAcl", "s3:ListBucket"]
resources = [local.bucket_arn]
}
statement {
sid = "config-bucket-delivery"
effect = local.config_effect
principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
dynamic "statement" {
for_each = { for k, v in local.config_accounts : k => v }
content {
sid = "config-bucket-delivery-${statement.key}"
effect = local.config_effect
principals {
type = "Service"
identifiers = ["config.amazonaws.com"]
}
actions = ["s3:PutObject", "s3:PutObjectAcl"]
condition {
test = "StringEquals"
variable = "AWS:SourceAccount"
values = [statement.value]
}
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
resources = ["${local.bucket_arn}/${local.config_logs_path}/${statement.value}/Config/*"]
}
actions = ["s3:PutObject"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
resources = local.config_resources
}
#
# ELB bucket policies
#
Expand Down

0 comments on commit 6d7fbb1

Please sign in to comment.