Skip to content

Instantly share code, notes, and snippets.

@christophetd
Created January 24, 2022 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophetd/5f70f5af787450e62fe8a7165825e787 to your computer and use it in GitHub Desktop.
Save christophetd/5f70f5af787450e62fe8a7165825e787 to your computer and use it in GitHub Desktop.
resource "aws_s3_bucket" "cloudtrail" {
bucket = local.bucket-name
force_destroy = true
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailAclCheck",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::${local.bucket-name}"
},
{
"Sid": "AWSCloudTrailWrite",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::${local.bucket-name}/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
]
}
POLICY
}
output "cloudtrail_trail_name" {
value = aws_cloudtrail.trail.name
}
output "display" {
value = format("CloudTrail trail %s ready", aws_cloudtrail.trail.arn)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment