【发布时间】:2015-11-02 19:54:39
【问题描述】:
我的 CFN 模板出现问题。我在参数中定义了一个 CIDR 块,并希望将其用作安全组资源中的CidrIp。
但是,当我运行堆栈时,我收到 Value of property CidrIp must be of type String 错误并且堆栈正在回滚。
这是我最小的失败模板。我想使用VPCCidrBlock 来定义CidrIp。
有趣的是,AWS 的样本模板LAMP_Multi_AZ 做了完全相同的事情。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A cloud VPC",
"Metadata": {
},
"Resources": {
"myvpc": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": {
"Ref": "VPCCidrBlock"
}
}
},
"SipserverSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable VPC access",
"VpcId": {
"Ref": "myvpc"
},
"SecurityGroupIngress": [
{ "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": { "Ref": "VPCCidrBlock" } },
{ "IpProtocol": "udp", "FromPort": "5060", "ToPort": "5060", "CidrIp": { "Ref:": "VPCCidrBlock" } }
]
}
}
},
"Parameters": {
"VPCCidrBlock": {
"Description": "Main CIDR block for the whole VPC",
"Type": "String",
"MinLength": "9",
"MaxLength": "18",
"Default": "10.13.0.0/16",
"AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
"ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
}
}
}
【问题讨论】:
-
问题出在
"Ref:"而不是"Ref"。有趣的是它验证正常。
标签: amazon-web-services amazon-cloudformation