Joe
Joe

Reputation: 13111

AWS S3 CLI - how to get JSON with all current policies set on a bucket?

I am testing S3 commands from EC2.

How to list all policies currently set for a specific bucket? (in AWS Web Console - I can see that json but want to do that trough AWS CLI)

Also - how to create S3 bucket trough CLI (from EC2) and attach all the policies via JSON (or by adding configuration commands)?

Upvotes: 0

Views: 1724

Answers (1)

John Hanley
John Hanley

Reputation: 81416

There is only one S3 policy per bucket. This command will display this policy:

aws s3api get-bucket-policy --bucket my-bucket

This command will create a bucket:

aws s3 mb s3://mybucket --region us-west-1

This command will create attach a policy to a bucket:

aws s3api put-bucket-policy --bucket mybucket --policy file://policy.json

S3 get-bucket-policy

S3 make bucket

Example Bucket Policies

Upvotes: 1

Related Questions