Bucket policies
Bucket policies are important to protect the data in your bucket. They are used to define who can access your bucket and what they can do with the data in it.
Public access files
There are many cases where you want to make files in your bucket public. For example, you might want to host assets for your website or share files with the public. In these cases, you can set the bucket policy to allow public access to the files in your bucket.
Below is an example policy with public file access. Replace bucketname with the name of your Scalia bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::bucketname/*"
]
}
]
}You can save this policy as a JSON file and apply it to your bucket as follows: s3cmd setpolicy policy.json s3://bucketname
If you don't want to make your entire bucket public, you can also make individual files or paths public by setting the Resource property to the desired value.