简体   繁体   English

嵌套 CloudFormation - 子模板未拾取参数

[英]Nested CloudFormation - Child template not picking up Parameter

I am building a nested CloudFormation template to build an EKS cluster, node group and associated roles.我正在构建一个嵌套 CloudFormation 模板来构建 EKS 集群、节点组和相关角色。 IAM stack builds just fine, when it begins the Cluster stack its failing with the following error; IAM 堆栈构建得很好,当它开始集群堆栈时,它失败并出现以下错误; "Parameters: [IAMRoleARN] do not exist in the template". “参数:模板中不存在 [IAMRoleARN]”。

Within the IAM stack, I've defined an Output/Export for the created role ARN;在 IAM 堆栈中,我为创建的角色 ARN 定义了一个输出/导出;

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

In my parent stack, I'm importing the export as part of my parameters for the Cluster child stack;在我的父堆栈中,我将导出作为集群子堆栈参数的一部分导入;

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

In the Cluster child stack, I have a top level parameter set up, that I then call on in the resources section;在集群子堆栈中,我设置了一个顶级参数,然后我在资源部分调用它;

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

Any ideas on what I may be missing is greatly appreciated!非常感谢我可能缺少的任何想法!

If you just want to export your ARN cross stack, your output should look like this:如果您只想导出 ARN 交叉堆栈,您的 output 应如下所示:

Outputs:
    ClusterRoleArn:
      Value: !GetAtt ClusterRole.Arn

Otherwise you would have to import it with否则,您将不得不使用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM