A bucket is private. To let others read it, you attach a bucket policy: a short JSON document that says who may do what.
json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::dragon-photos-2026/*"
}]
}| Part | Here | Means |
|---|---|---|
Effect | Allow | let it happen |
Principal | * | anyone at all |
Action | s3:GetObject | read an object, nothing more |
Resource | arn:aws:s3:::dragon-photos-2026/* | every object in this bucket |
Save it in a file, then attach it. file:// tells the command to read the policy from that file.
New command
aws s3api put-bucket-policy
Attaches a policy to a bucket. A new policy replaces the old one.
Usageaws s3api put-bucket-policy --bucket bucket --policy file://file
Example
aws s3api put-bucket-policy --bucket dragon-photos-2026 --policy file://public.json
Every bucket also has a safety switch, Block Public Access. While it is on, S3 refuses any policy that makes the bucket public, so nobody does it by mistake.