Creating bucket policies
Attach a policy to a bucket when you need to open it up (for example, public downloads or access for another S3 user) or lock it down (for example, only from your office IP range). If you're new to policies, read Bucket policies first, and start from one of the examples.
Before you start: create a bucket. Only the bucket owner can attach a policy.
Good practice
- Grant the smallest set of actions that does the job.
- Avoid
"Principal": "*"unless you really mean everyone, including anonymous users. - Add conditions, such as
aws:SourceIpors3:TlsVersion, to narrow access further. - Keep a copy of each policy in version control, and review policies from time to time.
In the web panel
- Go to S3 > Buckets and click the line with the bucket.
- In the right pane, click Manage bucket policy.
- Either upload a JSON file with your policy, or build it in Policy builder:
-
Click Add to add a statement.
-
Enter a Sid (statement ID). Letters and numbers only, no spaces.
-
Choose Allow or Deny.
-
Select the S3 actions.
-
Choose the resources: All objects in the bucket, or Select prefix or object and pick the folders or files with the folder icon.

-
Choose the principals: All S3 users, or Specify S3 users or domains and enter each one as
arn:aws:iam::<domain_id>:<user_id>.
-
Optionally, under Conditions, click Add, choose a condition key and operator, and enter the value.

-
Click Add to save the statement. Repeat for more statements.
-
- Check the result in JSON view. Click Download file to keep a copy.
- Click Save.
The active policy is shown on the bucket's Bucket policy tab.
With aws-cli
Save the policy as policy.json, then attach it:
cd ~
aws s3api put-bucket-policy --bucket <bucket> --policy file://policy.json --profile bamboozle
Check what's attached:
cd ~
aws s3api get-bucket-policy --bucket <bucket> --query Policy --output text --profile bamboozle
put-bucket-policy replaces any existing policy, so always upload the complete policy, not just the new statement.
Policy changes take a short time to apply everywhere. Wait a minute before testing.