diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 05619c0..b9ddd47 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -37,7 +37,7 @@ resource "aws_codepipeline" "codepipeline" { configuration = { S3Bucket = aws_s3_bucket.source_bucket.bucket - S3ObjectKey = aws_s3_bucket_object.source_object.key + S3ObjectKey = aws_s3_object.source_object.key } } } @@ -61,13 +61,28 @@ resource "aws_codepipeline" "codepipeline" { resource "aws_s3_bucket" "artifact_bucket" { # tfsec:ignore:AWS002 bucket = "notifications-test-artifact-bucket" +} + +resource "aws_s3_bucket_ownership_controls" "artifact_bucket" { + bucket = aws_s3_bucket.artifact_bucket.id + rule { + object_ownership = "BucketOwnerPreferred" + } +} + +resource "aws_s3_bucket_acl" "artifact_bucket" { + depends_on = [aws_s3_bucket_ownership_controls.artifact_bucket] + + bucket = aws_s3_bucket.artifact_bucket.id acl = "private" +} - server_side_encryption_configuration { - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } +resource "aws_s3_bucket_server_side_encryption_configuration" "artifact_bucket" { + bucket = aws_s3_bucket.artifact_bucket.id + + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" } } } @@ -75,22 +90,42 @@ resource "aws_s3_bucket" "artifact_bucket" { resource "aws_s3_bucket" "source_bucket" { # tfsec:ignore:AWS002 bucket = "notifications-test-source-bucket" - acl = "private" +} + +resource "aws_s3_bucket_ownership_controls" "source_bucket" { + bucket = aws_s3_bucket.source_bucket.id - versioning { - enabled = true + rule { + object_ownership = "BucketOwnerPreferred" } +} - server_side_encryption_configuration { - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } +resource "aws_s3_bucket_acl" "source_bucket" { + depends_on = [aws_s3_bucket_ownership_controls.source_bucket] + + bucket = aws_s3_bucket.source_bucket.id + acl = "private" +} + +resource "aws_s3_bucket_server_side_encryption_configuration" "source_bucket" { + bucket = aws_s3_bucket.source_bucket.id + + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" } } } -resource "aws_s3_bucket_object" "source_object" { +resource "aws_s3_bucket_versioning" "source_bucket" { + bucket = aws_s3_bucket.source_bucket.id + + versioning_configuration { + status = "Enabled" + } +} + +resource "aws_s3_object" "source_object" { bucket = aws_s3_bucket.source_bucket.bucket key = "test" content = "test"