문제


I came across of creating 2 subnet for elasticache to use via cloudformation template.

The code example is below.

"SubnetGroup" : {
"Type" : " "SubnetIds" : [ { "Ref" : "Subnet1" }, { "Ref" : "Subnet2" } ]",
"Properties" : {
    "Description" : "Cache Subnet Group",
    "SubnetIds" : [ { "Ref" : "Subnet1" }, { "Ref" : "Subnet2" } ]
}
}

I understand the logic of the object but what i don't know how to create is the

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

I dont know if the object aws:ec2::subnet is capable of creating a subnet for object "AWS::ElastiCache::SubnetGroup".

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

Can the code below create a subnet for "AWS::ElastiCache::SubnetGroup"?:

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

Or is there "AWS::ElastiCache::Subnet" to create a subnet for elasticache purpose only which I don't find in the docs?

도움이 되었습니까?

해결책

The answer is yes - you reference an AWS::EC2::Subnet from AWS::ElastiCache::SubnetGroup. Here is an example from my code:

The 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"
      }
    ]
  }
}

The subnet group:

"cachesubnetgroup": {
  "Type" : "AWS::ElastiCache::SubnetGroup",
  "Properties" : {
    "Description" : "Cache Subnet for UAT",
    "SubnetIds" : [ 
        { 
            "Ref" : "subnet9732c5f2" 
        }, 
        {   
            "Ref" : "AnotherSubnetId" 
        }
    ]
  }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top