Welcome to Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy Praful Bhuskute BlackSpy

How can I set an Amazon S3 bucket file to be publicly read-only by default?

Simple Steps to Set Amazon S3 bucket policy to public read-only access and ACL Enable using Bucket policy

Step 1:  Goto Amazon S3 bucket select the bucket that we need to give public access the click on Permissions tab

selected s3 bucket with permission tab selected

Step 2:  Permission Tab in that we need to select Bucket Policy Section and click on Edit Button

Bucket Policy Section edit button

Step 3:  Once you click on the edit button new page is open on that we need to add the following code and then replace the bucket with your S3 Bucket name as per image. 

The bucket policy, written in JSON, provides access to the objects stored in the bucket.

				
					{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "AllowPublicRead",
			"Effect": "Allow",
			"Principal": {
				"AWS": "*"
			},
			"Action": "s3:GetObject",
			"Resource": "arn:aws:s3:::bucket/*"
		}
	]
}
				
			

Make public using ACl is enabled policy

The bucket policy, written in JSON, provides access to the objects stored in the bucket.

				
					{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucket/*"
        }
    ]
}
				
			

Cross-origin resource sharing (CORS)

Cross-Origin Resource Sharing (CORS) is a mechanism or protocol that allows devices on one domain to access resources in other domains.

This allows you to access HTTPS files to the localhost server without the issue of cross-origin 

				
					[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST",
            "HEAD",
            "GET",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]
				
			

Drop your queries

Table of Contents

Have A Project In Mind? Let's Get To Work