作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试创建允许相同账户角色和跨账户角色的存储桶策略。
这里CicdDeploymentRoleArn
是跨账户角色arns的列表。
Parameters:
CicdDeploymentRoleArn:
Type: CommaDelimitedList
Description: >-
The ARN of the CICD deployment role that will need access to the S3
Default: >-
arn:aws:iam::xxx:role/preprod,arn:aws:iam::xxx:role/prod
InfraBucketPolicy:
Properties:
Bucket: !Ref InfraBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Action:
- "s3:*"
Effect: Allow
Principal:
AWS:
- !Sub "arn:aws:iam::${AWS::AccountId}:role/human-role/PowerUser2"
- !Ref CicdDeploymentRoleArn # How to refer list here ?
Resource:
- !Join [ "", [ !GetAtt InfraBucket.Arn, "/*" ] ]
Type: "AWS::S3::BucketPolicy"
最佳答案
您可以通过组合 Split
和 Join
来完成此操作(必须小心缩进):
InfraBucketPolicy:
Properties:
Bucket: !Ref InfraBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Action:
- "s3:*"
Effect: Allow
Principal:
AWS:
!Split
- ","
- !Join
- ","
- - !Sub "arn:aws:iam::${AWS::AccountId}:role/human-role/PowerUser2"
- !Join [",", !Ref CicdDeploymentRoleArn]
Resource:
- !Join [ "", [ !GetAtt InfraBucket.Arn, "/*" ] ]
Type: "AWS::S3::BucketPolicy"
关于amazon-web-services - AWS CFT 如何将列表参数附加到静态字符串选项列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70185773/
我是一名优秀的程序员,十分优秀!