https://github.com/hashicorp/learn-terraform-provider-versioning/blob/38292721561b5c9f6030a7730e7faadf3a1e873f/main.tf#L16C3-L16C25
Received the following error on the initial Terraform Apply
step instead of the deprecation warning output as referenced in the tutorial:
aws_s3_bucket.sample: Creating...
Error: Error creating S3 bucket: InvalidBucketAclWithObjectOwnership: Bucket cannot have ACLs set with ObjectOwnership's BucketOwnerEnforced setting
│ status code: 400
Possibly due to changes made April 2023: ARTICLE
Was able to workaround and finish the tutorial by commenting out referenced line 16 in main.tf file and running Terraform Apply
The bucket is then created with defaults, and the tutorial can move forward to the ACL change section. However, the ACL manual change referenced in the article also fail on the next Terraform Apply
step presumably for the same reason as the above issue cause:
resource "aws_s3_bucket_acl" "example" {
bucket = aws_s3_bucket.sample.id
acl = "public-read"
}
aws_s3_bucket_acl.example: Creating...
│ Error: creating S3 bucket ACL for [my-example-bucket]: AccessDenied: Access Denied
│ status code: 403
The following ACL block appears to accomplish public access:
resource "aws_s3_bucket_ownership_controls" "example" {
bucket = random_pet.petname.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}
resource "aws_s3_bucket_public_access_block" "example" {
bucket = random_pet.petname.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_acl" "example" {
depends_on = [
aws_s3_bucket_ownership_controls.example,
aws_s3_bucket_public_access_block.example,
]
bucket = random_pet.petname.id
acl = "public-read"
}