7

如何在使用CloudFormation模板時設置Redis ReplicationGroup標識? docs中的所有選項都沒有辦法做到這一點,您可以輕鬆地完成CLI。我的最終目標是擁有一個擁有3個集羣成員的Redis複製組,但我想選擇名稱而不是AWS爲我設置唯一的名稱。CloudFormation模板中的Elasticache複製組標識

這裏是我的模板的一個片段:

"Resources": { 
    "mqpReplicationGroup": { 
     "Type": "AWS::ElastiCache::ReplicationGroup", 
     "Properties": { 
     "CacheNodeType": { 
      "Ref": "CacheNodeType" 
     }, 
     "CacheSubnetGroupName": { 
      "Ref": "CacheSubnets" 
     }, 
     "ReplicationGroupDescription": "Redis Replication Group", 
     "Engine": "redis", 
     "EngineVersion": { 
      "Ref": "RedisVersion" 
     }, 
     "NumCacheClusters": { 
      "Ref": "NumberOfCacheNodes" 
     }, 
     "AutoMinorVersionUpgrade": "true", 
     "AutomaticFailoverEnabled": "true", 
     "PreferredMaintenanceWindow": "sat:09:25-sat:22:30", 
     "SnapshotRetentionLimit": "4", 
     "SnapshotWindow": "00:05-05:30", 
     "NotificationTopicArn": { 
      "Fn::Join" :[":",["arn:aws:sns",{ "Ref" : "AWS::Region" },{ "Ref" : "AWS::AccountId" },"service-aws"]] 
     }, 
     "SecurityGroupIds": [ 
      { 
      "Fn::Join": [ 
       ",", 
       { 
       "Ref": "VpcSecurityGroupIds" 
       } 
      ] 
      } 
     ] 
     } 
    }, 
    "CacheSubnets": { 
     "Type": "AWS::ElastiCache::SubnetGroup", 
     "Properties": { 
     "Description": "mqp-cache-subnet", 
     "SubnetIds": { 
      "Ref": "SubnetIds" 
     } 
     } 
    } 
    } 

回答

5

截至2017年,現在可以使用ReplicationGroupId屬性。

由於它是可選的,因此AWS CloudFormation在未指定時仍會生成唯一的物理ID。

限制爲Name Type

  • 必須包含1至20個字母數字字符或連字符。
  • 第一個字符必須是字母。
  • 不能以連字符結尾或包含兩個連續的連字符。