【问题标题】:Cloudformation - ElastiCache::SubnetGroup not honouring resource nameCloudformation - ElastiCache::SubnetGroup 不遵守资源名称
【发布时间】:2017-01-15 10:00:55
【问题描述】:

我有一个关于 CloudFormation 的奇怪问题,这似乎是一个错误,或者更有可能是 - 我错过了一些非常基本的东西。

我有以下定义两个子网和一个子网组的模板(sn-p),如下所示:

...

"redissubnet1": {
  "Type": "AWS::EC2::Subnet",
  "Properties": {
    "CidrBlock": "10.0.8.0/24",
    "AvailabilityZone": "us-east-1c",
    "VpcId": {
      "Ref": "myVPC"
    },
    "Tags": [
      {
        "Key": "Name",
        "Value": "redissubnet1"
      }
    ]
  }
},
"redissubnet2": {
  "Type": "AWS::EC2::Subnet",
  "Properties": {
    "CidrBlock": "10.0.9.0/24",
    "AvailabilityZone": "us-east-1c",
    "VpcId": {
      "Ref": "myVPC"
    },
    "Tags": [
      {
        "Key": "Name",
        "Value": "redissubnet2"
      }
    ]
  }
},
"SubnetGroupName": {
  "Type": "AWS::ElastiCache::SubnetGroup",
  "Properties": {
    "Description": "Subnet group for main application redis elastic cache",
    "SubnetIds": [
      {
        "Ref": "redissubnet1"
      },
      {
        "Ref": "redissubnet2"
      }
    ]
  }
}

...

所有资源都已创建,但子网组名称 - “SubnetGroupName” - 未得到尊重。 AWS 自动分配格式为 [a-z]-[a-z]-[a-z0-9]

的名称

有人遇到过吗?

我实际上想要做的是在创建 ElastiCache::Cluster 时按名称引用这个子网组 - 但是因为资源名称不被尊重,所以我不能这样做。

有人有什么想法吗?感谢所有帮助:)

【问题讨论】:

  • 哈哈,自己解决了。答案是引用子网组名称。下面是完整的sn-p

标签: amazon-web-services amazon-elasticache amazon-cloudformation


【解决方案1】:

答案是引用弹性缓存资源中的子网组名,如下:

{
"subnet1": {
    "Type": "AWS::EC2::Subnet",
    "Properties": {
        "CidrBlock": "10.0.8.0/24",
        "AvailabilityZone": "us-east-1c",
        "VpcId": {
            "Ref": "myVPC"
        },
        "Tags": [{
            "Key": "Name",
            "Value": "subnet1"
        }]
    }
},
"subnet2": {
    "Type": "AWS::EC2::Subnet",
    "Properties": {
        "CidrBlock": "10.0.9.0/24",
        "AvailabilityZone": "us-east-1c",
        "VpcId": {
            "Ref": "myVPC"
        },
        "Tags": [{
            "Key": "Name",
            "Value": "subnet2"
        }]
    }
},
"redis1": {
    "Type": "AWS::ElastiCache::SubnetGroup",
    "Properties": {
        "Description": "Subnet group for main application redis elastic cache",
        "SubnetIds": [{
            "Ref": "subnet1"
        }, {
            "Ref": "subnet2"
        }]
    }
},
"mainredis": {
    "Type": "AWS::ElastiCache::CacheCluster",
    "Properties": {
        "AutoMinorVersionUpgrade": "true",
        "CacheNodeType": "cache.t2.small",
        "CacheSubnetGroupName": {
            "Ref": "redis1"
        },
        "ClusterName": "mainredis",
        "Engine": "redis",
        "NumCacheNodes": "1",
        "Port": "6379",
        "Tags": [{
            "Key": "Name",
            "Value": "mainredis"
        }, {
            "Key": "Function",
            "Value": "Main redis store"
        }],
        "VpcSecurityGroupIds": [
            "redissecuritygroup"
        ]
    }
  }
}

【讨论】:

    猜你喜欢
    • 2016-02-05
    • 1970-01-01
    • 2021-10-31
    • 2019-06-15
    • 1970-01-01
    • 2016-10-17
    • 2014-09-10
    • 2020-11-16
    • 2011-11-02
    相关资源
    最近更新 更多