Created
March 23, 2022 21:49
-
-
Save conzy/e5eb0466171dd5209ffc202bce8e3b6b to your computer and use it in GitHub Desktop.
Bucket policy that allows multiple accounts for AWS Config bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_iam_policy_document" "config_organization" { | |
statement { | |
principals { | |
identifiers = ["config.amazonaws.com"] | |
type = "Service" | |
} | |
actions = ["s3:GetBucketAcl"] | |
resources = [module.config_bucket.bucket_arn] | |
condition { | |
test = "StringEquals" | |
values = var.account_ids | |
variable = "AWS:SourceAccount" | |
} | |
} | |
statement { | |
principals { | |
identifiers = ["config.amazonaws.com"] | |
type = "Service" | |
} | |
actions = ["s3:ListBucket"] | |
resources = [ | |
module.config_bucket.bucket_arn, | |
] | |
condition { | |
test = "StringEquals" | |
values = var.account_ids | |
variable = "AWS:SourceAccount" | |
} | |
} | |
statement { | |
principals { | |
identifiers = ["config.amazonaws.com"] | |
type = "Service" | |
} | |
actions = ["s3:PutObject"] | |
resources = [for account in var.account_ids : "${module.config_bucket.bucket_arn}/AWSLogs/${account}/*"] | |
condition { | |
test = "StringEquals" | |
values = ["bucket-owner-full-control"] | |
variable = "s3:x-amz-acl" | |
} | |
condition { | |
test = "StringEquals" | |
values = var.account_ids | |
variable = "AWS:SourceAccount" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment