Skip to content

Commit f564fc8

Browse files
authored
Merge pull request #14 from chris-qa-org/add-bucket-ownership-controls
Add bucket ownership controls
2 parents be4b09e + f0e8718 commit f564fc8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ module "static_site_hosting" {
9696
| [aws_s3_bucket_acl.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |
9797
| [aws_s3_bucket_acl.static_site](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |
9898
| [aws_s3_bucket_logging.static_site](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_logging) | resource |
99+
| [aws_s3_bucket_ownership_controls.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
100+
| [aws_s3_bucket_ownership_controls.static_site](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
99101
| [aws_s3_bucket_policy.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
100102
| [aws_s3_bucket_policy.static_site](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
101103
| [aws_s3_bucket_public_access_block.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |

s3-logs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ resource "aws_s3_bucket_versioning" "logs" {
1616
}
1717
}
1818

19+
resource "aws_s3_bucket_ownership_controls" "logs" {
20+
count = local.create_logs_bucket ? 1 : 0
21+
22+
bucket = aws_s3_bucket.logs[0].id
23+
24+
rule {
25+
object_ownership = "BucketOwnerPreferred"
26+
}
27+
}
28+
1929
resource "aws_s3_bucket_acl" "logs" {
2030
count = local.enable_s3_access_logs ? 1 : 0
2131

s3-static-site.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ resource "aws_s3_bucket_logging" "static_site" {
1818
target_prefix = "s3/static_site/"
1919
}
2020

21+
resource "aws_s3_bucket_ownership_controls" "static_site" {
22+
bucket = aws_s3_bucket.static_site.id
23+
24+
rule {
25+
object_ownership = "BucketOwnerPreferred"
26+
}
27+
}
28+
2129
resource "aws_s3_bucket_acl" "static_site" {
2230
bucket = aws_s3_bucket.static_site.id
2331
acl = local.static_site_s3_acl

0 commit comments

Comments
 (0)