gpt4 book ai didi

amazon-web-services - AWS CFT 如何将列表参数附加到静态字符串选项列表

转载 作者:行者123 更新时间:2023-12-03 07:19:55 24 4
gpt4 key购买 nike

尝试创建允许相同账户角色和跨账户角色的存储桶策略。

这里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"

最佳答案

您可以通过组合 SplitJoin 来完成此操作(必须小心缩进):

  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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com