【问题标题】:Nested CloudFormation - Child template not picking up Parameter嵌套 CloudFormation - 子模板未拾取参数
【发布时间】:2021-05-19 15:06:59
【问题描述】:

我正在构建嵌套 CloudFormation 模板来构建 EKS 集群、节点组和关联角色。 IAM 堆栈构建得很好,当它开始集群堆栈时,它失败并出现以下错误; "参数:[IAMRoleARN] 模板中不存在"。

在 IAM 堆栈中,我为创建的角色 ARN 定义了输出/导出;

 Outputs:
    ClusterRoleArn:
      Value: !GetAtt ClusterRole.Arn
      Description: EKS cluster role ARN
      Export:
        Name: 
          Fn::Sub: "${AWS::StackName}-ClusterRoleArn"

在我的父堆栈中,我将导出作为集群子堆栈参数的一部分导入;

EksClusterStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: '{bucket name withheld}'
      Parameters:
        EksVpc: !Ref EksStackVpc
        ClusterName: !Ref EksClusterName
        IAMRoleARN:
          Fn::GetAtt:
            - EksIamStack
            - Outputs.ClusterRoleArn
        VpcSecurityGroup: !Ref EksVpcSecurityGroup
        ClusterSubnet1: !Ref EksSubnet1
        ClusterSubnet2: !Ref EksSubnet2

在集群子堆栈中,我设置了一个顶级参数,然后我在资源部分中调用它;

Parameters:
  IAMRoleARN:
    Type: String
    Description: ARN of the IAM role created for the cluster in the 
                 EKS IAM stack

Cluster:
  Type: "AWS::EKS::Cluster"
  Properties:
    Name: !Ref ClusterName
    Version: "1.19"
    RoleArn: !Ref IAMRoleARN
    ResourcesVpcConfig:
      SecurityGroupIds:
        - !Ref ClusterControlPlaneSecurityGroup
        - !Ref VpcSecurityGroup
      SubnetIds:
        - !Ref ClusterSubnet1
        - !Ref ClusterSubnet2

非常感谢任何关于我可能遗漏的想法!

【问题讨论】:

  • 你能始终提供整个资源和参数等整个部分吗?否则真的很混乱
  • 更新了来自每个堆栈的更多信息

标签: amazon-web-services amazon-cloudformation


【解决方案1】:

如果您只想导出 ARN 交叉堆栈,您的输出应如下所示:

Outputs:
    ClusterRoleArn:
      Value: !GetAtt ClusterRole.Arn

否则你将不得不使用

Fn::ImportValue: !Sub ${AWS::StackName}-ClusterRoleArn

【讨论】:

    猜你喜欢
    • 2018-08-17
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    相关资源
    最近更新 更多