如何为AWS ElastiCache创建子网?

时间:2014-02-03 04:01:09

标签: amazon-cloudformation amazon-elasticache


我遇到了通过cloudformation模板创建2个弹性缓存子网。

代码示例如下。

"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”创建子网。

*"SubnetIds" : [ { "Ref" : "**Subnet1**" }, { "Ref" : "**Subnet2**" } ]*

以下代码是否可以为“AWS :: ElastiCache :: SubnetGroup”创建子网?:

"Subnet": {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
  "AvailabilityZone" : String,
  "CidrBlock" : String,
  "Tags" : [ EC2 Tag, ... ],
  "VpcId" : { "Ref" : String }
}
}  

或者是否有“AWS :: ElastiCache :: Subnet”来创建一个仅用于弹性目的的子网,我在文档中找不到它?

1 个答案:

答案 0 :(得分:0)

答案是肯定的 - 您从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" 
        }
    ]
  }
}