0

我遇到了通过 cloudformation 模板为 elasticache 创建 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”来创建一个仅用于弹性缓存目的的子网,我在文档中没有找到?

4

1 回答 1

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" 
        }
    ]
  }
}
于 2014-05-24T14:51:53.833 回答