Reputation: 849
What is advisable when one needs an IAM policy for more than two buckets? Bucket names are pretty different from one another.
If 1 is the answer, can someone help with an example of read/write permissions on two buckets 1. bucket-a 2. bucket-b
Upvotes: 3
Views: 1751
Reputation: 81386
Are you creating IAM User Policies or S3 Bucket Policies? I will assume S3 bucket policies for this answer.
S3 buckets can only have one policy applied at a time.
This S3 bucket policy will grant anonymous access to read (get) and write (put) objects for two buckets. Note, the anonymous users will not be able to list objects.
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":[
"s3:GetObject",
"s3:PutObject"
],
"Resource":[
"arn:aws:s3:::bucket-a/*",
"arn:aws:s3:::bucket-b/*"
]
}
]
}
Specifying Permissions in a Policy
Upvotes: 4