amazon-web-services - 嵌套 CloudFormation - 子模板未获取参数

标签 amazon-web-services aws-cloudformation

我正在构建一个嵌套的 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

非常感谢任何有关我可能缺少的内容的想法!

最佳答案

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

Outputs:
    ClusterRoleArn:
      Value: !GetAtt ClusterRole.Arn

否则你将不得不导入它

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

关于amazon-web-services - 嵌套 CloudFormation - 子模板未获取参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67605906/

相关文章:

python - 使用 mrjob python 将 Comomn 爬网位置作为 Amazon EMR 的输入

php - AWS KMS - 存储/使用密文 Blob

amazon-web-services - 没有默认vpc的ec2 cloudformation模板

amazon-web-services - AWS Lambda 无法删除 Amazon S3 对象

amazon-web-services - 带有Lambda和S3的AWS ElasticSearch不会将文档添加到索引

amazon-web-services - 让 CloudFormation Stack 自删除的最佳方法是什么?

amazon-web-services - CloudFormation 删除 ASG 时未调用 Auto Scaling 组生命周期 Hook

amazon-web-services - Cloudformation复杂参数文件

amazon-web-services - AWS CloudFormation 中的子字符串

sql-server - 无法在 ap-southeast-2 中创建 db.r3.8xlarge SQL Server EE 实例