简体   繁体   English

AWS Cloudformation将值传递给嵌套堆栈

[英]AWS cloudformation pass value to nested stack

I'm having trouble creating stacks using nested stacks. 我在使用嵌套堆栈创建堆栈时遇到了麻烦。 I have one master template (the one listed is for testing, and is only reference one nested stack). 我有一个主模板(列出的一个用于测试,并且仅引用一个嵌套堆栈)。 I am trying to figure out how to pass a value from the master to the nested stack, or is there a better way to do this? 我试图弄清楚如何将值从母版传递到嵌套堆栈,还是有更好的方法呢? Every time try to create the stack, I get a: 每次尝试创建堆栈时,我都会得到:

Template format error: Unresolved resource dependencies [VpcCidrBlock] in the Resources block of the template.

Which I understand means the parameter I put in the master stack is not getting passed to the nested stack. 据我了解,这意味着我放入主堆栈中的参数没有传递给嵌套堆栈。

Master Template: 主模板:

{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Description" : "Master template",
    "Parameters" : {
        "availabilityZone" : {
            "Default" : "us-east-1d",
            "Description" : "Enter AvailabilityZone.",
            "Type" : "String"
        },
        "VpcCidrBlock" : {
            "Default" : "10.0.0.0/16",
            "Description" : "VPC CIDR Block.",
            "Type" : "String"
        }
    },
    "Resources" : {
        "VPCStack" : {
            "Type" : "AWS::CloudFormation::Stack",
            "Properties" : {
                "TemplateURL" : "https://s3.amazonaws.com/dev.url.templates/templates/vpcStack.json",
                "TimeoutInMinutes" : "5",
                "Parameters" : {
                    "VpcCidrBlock" : {
                        "Ref" : "VpcCidrBlock"
                    }
                }
            }
        }
    }
}

VPC Template: VPC模板:

{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Description" : "VPC template",
    "Resources" : {
        "VpcStack" : {
            "Type" : "AWS::EC2::VPC",
            "Properties" : {
                "EnableDnsSupport" : "true",
                "EnableDnsHostnames" : "true",
                "CidrBlock" : {
                    "Ref" : "VpcCidrBlock"
                },
                "Tags" : [
                    {
                        "Key" : "Application",
                        "Value" : {
                            "Ref" : "AWS::StackName"
                        }
                    }
                ]
            }
        }
    }
}

Thanks! 谢谢!

Your internal template needs an input parameter: 您的内部模板需要一个输入参数:

"Parameters" : {
    "VpcCidrBlock" : {
        "Description" : "VPC CIDR Block.",
        "Type" : "String"
    }
},

Just like your outer "wrapper" template. 就像您的外部“包装”模板一样。

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

相关问题 AWS CloudFormation CodePipeline、ParameterOverrides、将列表传递给嵌套堆栈 - AWS CloudFormation CodePipeline, ParameterOverrides, pass list to a nested stack 如何将列表传递给AWS CloudFormation中的嵌套堆栈参数? - How to pass a list to a nested stack parameter in AWS CloudFormation? 将堆栈标记传递给Cloudformation中的嵌套堆栈 - Pass stack tags to nested stack in Cloudformation AWS 无服务器框架:嵌套堆栈或 Cloudformation 模板 - AWS Serverless framework : Nested Stack or Cloudformation templates 在 AWS cloudformation 上理解 Apigateway 和嵌套堆栈时出错 - Error understanding Apigateway and nested stack on AWS cloudformation 将安全 SSM 参数传递给嵌套的 CloudFormation 堆栈 - Pass secure SSM parameter to a nested CloudFormation stack CloudFormation 将所有参数从根堆栈传递到嵌套堆栈 - CloudFormation Pass All Parameters from Root Stack to Nested Stack 有没有办法在 AWS cloudformation 中配置嵌套堆栈的“堆栈名称”? - Is there a way to configure the 'Stack Name' of nested stacks in AWS cloudformation ? AWS CloudFormation 堆栈:具有嵌套路径的 API 网关资源? - AWS CloudFormation stack: API Gateway resource with nested paths? Cloudformation AWS CLI 查询具有多个嵌套堆栈的所有堆栈资源 - Cloudformation AWS CLI Query ALL Stack resources with multiple nested stacks
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM