gpt4 book ai didi

amazon-web-services - 获取 "Template validation error: Invalid template resource property ' VPCID'"

转载 作者:行者123 更新时间:2023-12-03 07:28:48 26 4
gpt4 key购买 nike

我正在尝试使用 AWS CloudFormation 创建 VPC。

我自己构建了一个 VPC,然后通过向 JSON 模板添加更多组件(子网、互联网网关、NAT、路由表等组件)来更新现有堆栈 - 一次一个组件。

我的 VPC 已成功创建,但当我尝试使用 Internet 网关更新堆栈并附加到 VPC 时,我开始收到错误模板验证错误:模板资源属性“VPCID”无效

我的JSON模板如下:

{
"Parameters": {
"CIDRRange": {
"Description": "VPCCIDR Range (will be a /16 block)",
"Type": "String",
"Default": "10.251.0.0",
"AllowedValues": ["10.250.0.0","10.251.0.0"]
}
},

"Resources": {
"VPCBase": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": { "Fn::Join" : ["", [{ "Ref" : "CIDRRange" }, "/16"]] },
"EnableDnsSupport": "True",
"EnableDnsHostnames": "True",
"Tags": [{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-VPC"]] } }]
}
},

"IGWBase" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-IGW"]] } }]
}
},

"VGAIGWBase" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"InternetGatewayId" : { "Ref" : "IGWBase" },
"VpcId" : { "Ref" : "VPCBase" }}
},

"Outputs": {
"VPCID" : { "Value" : { "Ref" : "VPCBase" } },
"DefaultSG" : { "Value" : { "Fn::GetAtt" : ["VPCBase", "DefaultSecurityGroup"] }}
}
}
}

最佳答案

您的格式有点困惑 - 我建议使用 yaml 而不是 json - 但问题是您没有关闭 Resources: 部分。

您可以使用 cli 验证模板:

aws cloudformation validate-template --template-body file://path.json



"VGAIGWBase" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"InternetGatewayId" : { "Ref" : "IGWBase" },
"VpcId" : { "Ref" : "VPCBase" }
}
}
}, << ADD THIS

"Outputs": {
"VPCID" : { "Value" : { "Ref" : "VPCBase" } },
"DefaultSG" : { "Value" : { "Fn::GetAtt" : ["VPCBase", "DefaultSecurityGroup"] }}
}
}

关于amazon-web-services - 获取 "Template validation error: Invalid template resource property ' VPCID'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46749896/

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