首页 > 解决方案 > AWS cloudformation:创建 AWS::ElastiCache::ReplicationGroup 资源时如何设置集群名称

问题描述

我在 AWS::ElastiCache::ReplicationGroup 类型的模板中有一个资源。创建堆栈时,它会在创建此集群时分配生成的名称。正在使用 Redis 引擎。对于 AWS::ElastiCache::CacheCluster,有一个名为 ClusterName 的属性用于相同目的。这里有对应的属性吗?

标签: amazon-web-servicesamazon-cloudformation

解决方案


对我来说,设置 ReplicationGroupId 属性是有效的。我使用了一个名为“ClusterName”的输入参数。

Resources:
  RedisReplicationGroup:
    DependsOn: SecurityGroup
    Type: AWS::ElastiCache::ReplicationGroup
    Properties: 
      AtRestEncryptionEnabled: !Ref AtRestEncryptionEnabled
      AuthToken: !Ref AuthToken
      AutomaticFailoverEnabled: !Ref AutomaticFailoverEnabled
      CacheNodeType: !Ref CacheNodeType
      CacheParameterGroupName: !Ref CacheParameterGroupName
      CacheSubnetGroupName: !Ref CacheSubnetGroupName
      Engine: redis
      NumNodeGroups: !Ref NumNodeGroups
      ReplicationGroupId: !Ref ClusterName
      ReplicasPerNodeGroup: !Ref ReplicasPerNodeGroup
      ReplicationGroupDescription: "Redis Cluster"
      SecurityGroupIds: 
        - !Ref SecurityGroup
      Tags:
        - 
          Key: "Environment"
          Value: !Ref EnvironmentTag
        - 
          Key: "Name"
          Value: !Ref ClusterName
        -
          Key: "CreatedBy"
          Value: !Ref CreatedByTag
        -
          Key: "Project"
          Value: !Ref ProjectTag
      TransitEncryptionEnabled: !Ref TransitEncryptionEnabled

推荐阅读