【问题标题】:How do I create a subnet for AWS ElastiCache?如何为 AWS ElastiCache 创建子网?
【发布时间】:2014-05-24 22:51:53
【问题描述】:

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

【问题讨论】:

    标签: amazon-cloudformation amazon-elasticache


    【解决方案1】:

    答案是肯定的 - 您从 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。还尝试在子网组中指定 VPC ID 并获取“遇到不支持的属性 VpcId”
    猜你喜欢
    • 2016-02-05
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-12-22
    • 2017-07-10
    相关资源
    最近更新 更多