更改云形成模板中的 ElastiCache 节点 DNS 记录

Kat*_*ate 3 amazon-web-services amazon-elasticache aws-cloudformation amazon-route53

我需要为 ElastiCache 集群创建 CNAME 记录。但是,我构建了redis集群,并且只有一个节点。据我发现 redis 集群没有 ConfigurationEndpoint.Address 。是否有机会更改集群中节点的 DNS 名称以及如何更改?

目前模板看起来像:

  "ElastiCahceDNSRecord" : {
  "Type" : "AWS::Route53::RecordSetGroup",
  "Properties" : {
    "HostedZoneName" : "example.com.",
    "Comment" : "Targered to ElastiCache",
    "RecordSets" : [{
    "Name" : "elche01.example.com.",
    "Type" : "CNAME",
    "TTL" : "300",
    "ResourceRecords" :  [
        {
            "Fn::GetAtt": [ "myelasticache", "ConfigurationEndpoint.Address" ]
        }
    ]

    }]

  }
Run Code Online (Sandbox Code Playgroud)

}

sli*_*ive 5

对于来到此页面寻求解决方案的人们。现在有一种方法可以直接从 CFN 中获取 Redis 端点。

现在有能力RedisEndpoint.AddressAWS::ElastiCache::CacheClusterPrimaryEndPoint.AddressAWS::ElastiCache::ReplicationGroup

根据文档(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticache-cache-cluster.html):

RedisEndpoint.Address - Redis 缓存集群的配置端点的 DNS 地址。

RedisEndpoint.Port - Redis 缓存集群的配置端点的端口号。

或者

根据文档(http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html):

PrimaryEndPoint.Address - 主要读写缓存节点的 DNS 地址。

PrimaryEndPoint.Port - 主要读写缓存引擎正在侦听的端口号。

一个示例 CFN(不包括其他位):

Resources:
  DnsRedis:
    Type: 'AWS::Route53::RecordSetGroup'
    Properties:
      HostedZoneName: 'a.hosted.zone.name.'
      RecordSets:
        - Name: 'a.record.set.name'
          Type: CNAME
          TTL: '300'
          ResourceRecords:
            - !GetAtt
              - RedisCacheCluster
              - RedisEndpoint.Address  
    DependsOn: RedisCacheCluster

  RedisCacheCluster:
    Type: 'AWS::ElastiCache::CacheCluster'
    Properties:
      ClusterName: cluster-name-redis
      AutoMinorVersionUpgrade: 'true'
      AZMode: single-az
      CacheNodeType: cache.t2.small
      Engine: redis
      EngineVersion: 3.2.4
      NumCacheNodes: 1
      CacheSubnetGroupName: !Ref ElastiCacheSubnetGroupId
      VpcSecurityGroupIds:
        - !GetAtt
          - elasticacheSecGrp
          - GroupId
Run Code Online (Sandbox Code Playgroud)