Reputation: 2814
Here are parameters - S3 bucket names list:
Parameters:
S3BucketNames:
Description: Enter S3 Bucket Names
Type: CommaDelimitedList
Default: my-first-bucket,testing-bucket,codepipeline-bucket
Need to make policy IAM Policy for GetObject, PutObject operations, when arn has to be in the following format suitable for IAM policy:
arn:${Partition}:s3:::${BucketName}/${ObjectName}
In my example it should look like:
"arn:aws:s3:::my-first-bucket/*",
"arn:aws:s3:::testing-bucket/*",
"arn:aws:s3:::codepipeline-bucket/*"
Upvotes: 1
Views: 1254
Reputation: 2814
I had to think a bit how I can pull it off, obvious when you know it, but maybe will be helpfull for someone:
S3RolePolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: DemoPolicy
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
Resource: !Split
- ","
- !Sub
- arn:aws:s3:::${S3Middle}/*
- S3Middle: !Join [ "/*,arn:aws:s3:::" , !Ref S3BucketNames ]
It's not a full CloudFormation template - just sample peace
Upvotes: 4