How to Make AWS S3 Bucket Public Readable
Recently I have been working in Personal Health Management App where medical record can be saved as image. For my production server I have used AWS S3 Bucket. The problem I have faced I can’t see the image from my mobile app due to aws s3 bucket policy restriction. So I have need to set my AWS S3 bucket policy.
There is a lot of AWS Bucket Policy. You can generate your policy using AWS Policy Generator. AWS S3 allows us to set permission on file basis or per bucket. In my case I need to make my bucket publicly readable for everyone. To set this you need to follow the below instruction:
-
Go to your AWS Management Console and you will see your buckets(see the image)
-
Select the bucket you wanna make public readable. Click the top permission tab and select below Bucket Policy tab(see the image).
-
Paste following code in the Bucket Policy Modal and save it.
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::<your-bucket-name>/*"
]
}
]
}
Don’t forget to put your bucket name in your-bucket-name option:
- After save the bucket policy you will see that your bucket public(see the image).
Some useful link that I have followed:
- https://futurestud.io/tutorials/how-to-make-aws-s3-bucket-public-readable
Note: If you have any query or any upgradation of my writing or any mistakes please comment and suggest me. You are warmly welcomed always.