cloudformation模板格式错误:每个Resources对象必须包含一个Type成员

时间:2017-01-15 22:46:56

标签: amazon-vpc amazon-cloudformation

嗨,我希望有人可以帮我告诉我我做错了什么。我正在编写一个CF模板,只是将一个VPN网关添加到VPC。无需更新路由表等。

我正在使用下面的模板,但是我收到一个错误,我无法完全看到问题,我认为额外的一双眼睛可能有帮助! : 模板验证错误:模板格式错误:每个Resources对象都必须包含Type成员。

模板:

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "CF Just add a VPN Gateway to a VPC ",

"Parameters" : {

"targetVPCtoAttachGatewayTo"    : {
        "Description"   : "VPC ID to attach VPN Gateway",
        "Default"       : "vpc-xxxxx",
        "Type": "AWS::EC2::VPC::Id" 
    }
},

"Resources" : {

"VPNGateway" : {
    "Type" : "AWS::EC2::VPNGateway",
    "Properties" : {
    "Type" : "ipsec.1",
    "Tags" : [
        {"Key": "Name", "Value": {"Fn::Join": ["",["Virtual Private Gateway for ", { "Ref": "targetVPCtoAttachGatewayTo"} ] ]}}]
    }
},

"AttachVpnGateway" : {
    "Type" : "AWS::EC2::VPCGatewayAttachment",
    "DependsOn" : "VPNGateway",
    "Properties" : {
    "VpcId" : { "Ref" : "targetVPCtoAttachGatewayTo" },
    "VpnGatewayId" : { "Ref" : "VPNGateway" }
    }
},

"Outputs" : {
}}}

1 个答案:

答案 0 :(得分:1)

解决了问题,大括号在错误的地方。下面的工作模板。

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "CF Just add a VPN Gateway to a VPC ",

"Parameters" : {

"targetVPCtoAttachGatewayTo"    : {
        "Description"   : "VPC ID to attach VPN Gateway",
        "Default"       : "vpc-xxxxx",
        "Type": "AWS::EC2::VPC::Id" 
    }
},

"Resources" : {

"VPNGateway" : {
    "Type" : "AWS::EC2::VPNGateway",
    "Properties" : {
    "Type" : "ipsec.1",
    "Tags" : [
        {"Key": "Name", "Value": {"Fn::Join": ["",["Virtual Private Gateway for ", { "Ref": "targetVPCtoAttachGatewayTo"} ] ]}}]
    }
},

"AttachVpnGateway" : {
    "Type" : "AWS::EC2::VPCGatewayAttachment",
    "DependsOn" : "VPNGateway",
    "Properties" : {
    "VpcId" : { "Ref" : "targetVPCtoAttachGatewayTo" },
    "VpnGatewayId" : { "Ref" : "VPNGateway" }
    }
    }
},

"Outputs" : {
}}