Search code examples
amazon-web-servicesamazon-s3terraform-provider-aws

Make S3 Bucket Public Using Terraform


I am trying to expose my bucket to the public using terraform. What am I doing wrong.

resource "aws_s3_bucket" "My_bucket" {
  bucket = "my-test-bucket-for-vpc-endpoints"
  tags = {
    Name = "My bucket"
  }
}

resource "aws_s3_bucket_acl" "example_bucket_acl" {
  bucket = aws_s3_bucket.My_bucket.id
  acl    = "public-read"
}

resource "aws_s3_bucket_public_access_block" "example" {
  bucket = aws_s3_bucket.My_bucket.id
}

Solution

  • I removed the below block

    resource "aws_s3_bucket_public_access_block" "example" {
      bucket = aws_s3_bucket.My_bucket.id
    }