How to block public access to S3 bucket using Terraform

0 votes
Hi Guys,

I have created an S3 bucket. I want to remove the public access from this bucket. How can I do that?
Sep 9, 2020 in Terraform by akhtar
• 38,180 points
2,681 views

1 answer to this question.

0 votes

Hi@akhtar,

To control the access of the S3 bucket you need to use the aws_s3_bucket_public_access_block resource in your Terraform code as shown below.

resource "aws_s3_bucket_public_access_block" "s3Public" {
bucket = "${aws_s3_bucket.bucket.id}"
block_public_acls = true
block_public_policy = true
restrict_public_buckets = true
}
answered Sep 9, 2020 by MD
• 95,140 points

Related Questions In Terraform

0 votes
1 answer

How to create one S3 bucket in AWS using Terraform?

Hi@akhtar, You need to set aws provider name ...READ MORE

answered Jul 23, 2020 in Terraform by MD
• 95,140 points
289 views
0 votes
1 answer

How to create a folder inside S3 Bucket using Terraform code?

Hi@akhtar, You can create a folder at the ...READ MORE

answered Jul 23, 2020 in Terraform by MD
• 95,140 points
578 views
0 votes
1 answer

How to copy the content of an s3 bucket to another s3 bucket using Terraform?

Hi@akhtar, There is no resource that enables the ...READ MORE

answered Sep 10, 2020 in Terraform by MD
• 95,140 points
1,036 views
0 votes
1 answer

How to import manually created s3 bucket in Terraform?

Hi@akhtar, Terraform will not able to get the ...READ MORE

answered Sep 10, 2020 in Terraform by MD
• 95,140 points
1,416 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,100 points
1,983 views
0 votes
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,100 points
2,724 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,810 points
1,525 views
0 votes
2 answers
0 votes
1 answer

How to create a folder in S3 bucket using terraform?

Hi@akhtar, You can use aws_s3_bucket_object resource to create one ...READ MORE

answered Jun 11, 2020 in Terraform by MD
• 95,140 points
2,862 views
0 votes
1 answer

How to create one s3 bucket using terraform?

Hi@akhtar, You can use aws_s3_bucket resources to create ...READ MORE

answered Jun 12, 2020 in Terraform by MD
• 95,140 points
2,158 views