Amazon cloudformation 如何为AWS ElastiCache创建子网?
我偶然发现通过cloudformation模板创建2个子网供elasticache使用 下面是代码示例Amazon cloudformation 如何为AWS ElastiCache创建子网?,amazon-cloudformation,amazon-elasticache,Amazon Cloudformation,Amazon Elasticache,我偶然发现通过cloudformation模板创建2个子网供elasticache使用 下面是代码示例 "SubnetGroup" : { "Type" : " "SubnetIds" : [ { "Ref" : "Subnet1" }, { "Ref" : "Subnet2" } ]", "Properties" : { "Description" : "Cache Subnet Group", "SubnetIds" : [ { "Ref" : "Subnet1" }, {
"SubnetGroup" : {
"Type" : " "SubnetIds" : [ { "Ref" : "Subnet1" }, { "Ref" : "Subnet2" } ]",
"Properties" : {
"Description" : "Cache Subnet Group",
"SubnetIds" : [ { "Ref" : "Subnet1" }, { "Ref" : "Subnet2" } ]
}
}
我理解对象的逻辑,但我不知道如何创建
"SubnetIds" : [ { "Ref" : "**Subnet1**" }, { "Ref" : "**Subnet2**" } ]
我不知道对象aws:ec2::subnet是否能够为对象“aws::ElastiCache::SubnetGroup”创建子网
下面的代码能否为“AWS::ElastiCache::SubnetGroup”创建子网
或者是否有“AWS::ElastiCache::Subnet”来创建仅用于ElastiCache目的的子网,而我在文档中找不到该子网?答案是肯定的-您引用了AWS::ElastiCache::SubnetGroup中的AWS::EC2::Subnet。下面是我的代码中的一个示例: 子网:
"subnet9732c5f2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.5.2.0/24",
"AvailabilityZone": "eu-west-1b",
"VpcId": {
"Ref": "vpcc140a7a4"
},
"Tags": [
{
"Key": "Name",
"Value": "Private subnet #2"
}
]
}
}
子网组:
"cachesubnetgroup": {
"Type" : "AWS::ElastiCache::SubnetGroup",
"Properties" : {
"Description" : "Cache Subnet for UAT",
"SubnetIds" : [
{
"Ref" : "subnet9732c5f2"
},
{
"Ref" : "AnotherSubnetId"
}
]
}
}
我收到错误“子网组属于不同的VPC”。Cloudformation正在尝试在默认VPC中创建子网组。而子网具有指定的专有网络。还尝试在子网组中指定VPC ID并获取“遇到不支持的属性VpcId”
"subnet9732c5f2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.5.2.0/24",
"AvailabilityZone": "eu-west-1b",
"VpcId": {
"Ref": "vpcc140a7a4"
},
"Tags": [
{
"Key": "Name",
"Value": "Private subnet #2"
}
]
}
}
"cachesubnetgroup": {
"Type" : "AWS::ElastiCache::SubnetGroup",
"Properties" : {
"Description" : "Cache Subnet for UAT",
"SubnetIds" : [
{
"Ref" : "subnet9732c5f2"
},
{
"Ref" : "AnotherSubnetId"
}
]
}
}