June 8, 2020 / Nirav Shah
In this blog, our AWS team will explain to you how can we create a secure bucket policy on S3.
Confusing about “secure bucket”???
Have you ever heard about “HTTP and HTTPS protocols”

The above image shows that https requests should be encrypted, so that no one hacker can hack our website.
Just the same thing we will step in AWS.
So now let’s get started with log in to your AWS console …… 🙂
Step 1
Go to the S3 console and create a bucket and add some objects on the bucket.
In our case, my bucket name is “mywebsite1996”
And we have created Two folders that are
In this blog, we can use the public folder,
Note
Our bucket is in publicly accessible,

So in our public folder, I have uploaded a pic of my AWS certification badge,
URL https://mywebsite1996.s3.amazonaws.com/public/AWS_Solutions_Architect_logo_aws_solutions_architect_aws_solutions_architect.png

Now change the URL http://mywebsite1996.s3.amazonaws.com/public/AWS_Solutions_Architect_logo_aws_solutions_architect_aws_solutions_architect.png
In both of the above images, we can say that the https request is very secure.

Step 2
Go to the “bucket policy” in the permission section

Step 3
So now we have to create a custom policy.
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::/public/*",
"Condition": {
"Bool": {
"aws:SecureTransport": "false"
}
}
}
]
}
Here my bucket name is “mywebsite1996”

And click on “save button”
On the above policy, you can see that we have denied the specific folder that is “public” ( you can also apply to the bucket)
Now go to the “public folder “ and open the object URL
Your URL looks like this,
https://mywebsite1996.s3.amazonaws.com/public/AWS_Solutions_Architect_logo_aws_solutions_architect_aws_solutions_architect.png

And click on the URL you will see the image, for here we have uploaded my certification badge

Now try to access the URL via http request
You will see this,
http://mywebsite1996.s3.amazonaws.com/public/AWS_Solutions_Architect_logo_aws_solutions_architect_aws_solutions_architect.png

Great, you finally did it……

Nirav Shah is the Director of Eternal Web Pvt Ltd, an AWS Advanced Consulting Partner and certified Odoo Partner based in the UK. With over a decade of experience in cloud computing, digital transformation, and ERP implementation, Nirav helps enterprises adopt the right technology to solve complex business challenges. He specialises in AWS infrastructure, Odoo ERP, and web development solutions for businesses across the UK and beyond.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.