我提供的IP CIDR在Cloudformation中似乎无效。 使用的IP:VPC(192.168.0.0/16)子网-192.168.0.0 / 24、192.168.64.0 / 24、192.168.128.0 / 24、192.168.192.0 / 24
我尝试手动创建VPC并按上面的说明添加子网,并且它可以正常工作。但是在Cloudformation中进行输入时,这是行不通的。
参数和资源代码:
"PublicSubnet1CIDR": {
"Description": "Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone",
"Type": "String",
"Default": "192.168.0.0/24",
"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."
},
答案 0 :(得分:1)
这是您的问题,在cloudformation片段中,您有以下内容:
"PrivateSubnet1" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : {
"Ref" : "VPC"
},
"CidrBlock" : "PrivateSubnet1CIDR",
"AvailabilityZone" : {
"Fn::Select" : [
"0",
{
"Fn::GetAZs" : "ap-south-1"
}
]
},
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "Name",
"Value": "Private Subnet (AZ1)"
}
]
}
}
请注意,对于CidrBlock的值,您没有引用参数,只是给了纯文本值“ PrivateSubnet1CIDR”。它应该看起来像这样:
"PrivateSubnet1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {
"Ref": "VPC"
},
"CidrBlock": {
"Ref": "PrivateSubnet1CIDR"
},
"AvailabilityZone": {
"Fn::Select": [
"0",
{
"Fn::GetAZs": "ap-south-1"
}
]
},
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "Name",
"Value": "Private Subnet (AZ1)"
}
]
}
}
请注意,您要引用的参数需要有一个“ Ref”,您不能只说出PrivateSubnet1CIDR这个词。
您还有其他一些相同问题的实例。