gpt4 book ai didi

amazon-web-services - 不应用 AWS 堆栈集实例的覆盖参数

转载 作者:行者123 更新时间:2023-12-03 07:16:31 27 4
gpt4 key购买 nike

下面的 CF 模板经过缩进,用于创建一个堆栈集,其中包含一个具有特定参数值的角色,具体取决于帐户所在的 OU。因此,如果帐户位于/创建于 OU A 中,则调试角色的信任关系必须指向帐户“111111111111”。

AWSTemplateFormatVersion: "2010-09-09"
Description: Debug Role
Resources:
StackSet:
Type: AWS::CloudFormation::StackSet
Properties:
Description: Debug Role Stack Set
PermissionModel: SERVICE_MANAGED
Capabilities:
- CAPABILITY_NAMED_IAM
AutoDeployment:
Enabled: true
RetainStacksOnAccountRemoval: false
Parameters:
- ParameterKey: TrustAccountId
ParameterValue: "123456789123" # default value
OperationPreferences:
RegionConcurrencyType: PARALLEL
FailureToleranceCount: 0
MaxConcurrentPercentage: 100
StackInstancesGroup:
- DeploymentTargets:
OrganizationalUnitIds:
- ou-aaaa # A
ParameterOverrides:
- ParameterKey: "TrustAccountId"
ParameterValue: "111111111111"
Regions:
- 'eu-central-1'
- DeploymentTargets:
OrganizationalUnitIds:
- ou-bbbb # B
ParameterOverrides:
- ParameterKey: "TrustAccountId"
ParameterValue: "222222222222"
Regions:
- 'eu-central-1'
StackSetName: debug-role-stack-set
TemplateBody: |
AWSTemplateFormatVersion: 2010-09-09
Description: Debug Role
Parameters:
TrustAccountId:
Description: Trust to account
Type: String
AllowedPattern: \d{12}
Resources:
DebugRole:
Type: AWS::IAM::Role
Description: "Role for debugging accounts"
Properties:
RoleName: DebugRole
Path: /
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS:
- Ref: TrustAccountId
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AdministratorAccess

现在的问题是,堆栈实例组中的所有帐户,无论是现有帐户还是新帐户,都会使用默认参数值“123456789123”应用堆栈。因此,所有帐户都会获得与“123456789123”具有不正确信任关系的角色。

根据 OU 应用正确值的唯一方法是使用 CLI 更新堆栈实例。

aws cloudformation update-stack-instances --stack-set-name debug-role-stack-set --deployment-targets OrganizationalUnitIds=ou-aaaa --regions eu-central-1 --operation-preferences FailureToleranceCount=0,MaxConcurrentCount=5 --parameter-overrides Pa
rameterKey=TrustAccountId,ParameterValue=111111111111

有没有办法在堆栈创建期间应用正确的参数值,而无需事后更新它们?因为对于每个新帐户,所有堆栈集实例都需要更新。

最佳答案

由于未使用正确的参数值执行堆栈实例,因此我最终为每个 OU 设置了一个堆栈。当然,这种方案只适用于静态环境。因此,就我而言,如果弹出新的 OU,则必须创建新的堆栈集。

关于amazon-web-services - 不应用 AWS 堆栈集实例的覆盖参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69159914/

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