Elasticache replication group id in CloudFormation

2019-03-27 13:44发布

问题:

How do you set the Redis ReplicationGroup ID when using a CloudFormation template? All the options in the docs show no way to do that and the CLI you can do this easily. My end goal is to have a Redis replication group with 3 cluster members but I want to choose the name rather than AWS set a unique name for me.

Here's a snippet of my template:

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

回答1:

As of 2017, this is now possible using ReplicationGroupId property.

Since it is optional, AWS CloudFormation will still generate an unique physical ID when not specified.

Restrictions for Name Type:

  • Must contain from 1 to 20 alphanumeric characters or hyphens.
  • First character must be a letter.
  • Cannot end with a hyphen or contain two consecutive hyphens.


回答2:

This cannot currently be done with CloudFormation.