I am trying to create Redis Cluster across the region. Using this below CloudFormation template I am not able to see the secondary cluster and global store. The template is:
AWSTemplateFormatVersion: '2010-09-09'
Description: 'redis cluster for sample application'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: 'ElastiCache Parameters'
Parameters:
- EngineVersion
- CacheNodeType
- TransitEncryption
#- AuthToken
- NumShards
- NumReplicas
- Label:
default: 'Alerting Parameters'
Parameters:
- CPUUtilizationThreshold
- DatabaseMemoryUsagePercentageThreshold
- SwapUsageThreshold
- EvictionsThreshold
- ReplicationLagThreshold
Parameters:
EngineVersion:
Description: 'Redis version'
Type: String
Default: '7.0'
AllowedValues: ['7.0', '6.2', '6.0', '5.0.6', '5.0.5', '5.0.4', '5.0.3', '5.0.0', '4.0.10', '3.2.6'] # aws elasticache describe-cache-engine-versions --engine redis --query "CacheEngineVersions[].EngineVersion"
CacheNodeType:
Description: 'The compute and memory capacity of the nodes in the node group (shard).'
Type: 'String'
Default: 'cache.m5.xlarge'
TransitEncryption:
Description: 'Enable encryption for data in transit? (see https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/in-transit-encryption.html)'
Type: 'String'
Default: 'true'
AllowedValues:
- 'true'
- 'false'
AccountEnv:
Description: 'Type of Environment.'
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/account/environment'
NumShards:
Description: 'Number of shards in the cluster.'
Type: 'Number'
Default: 2
MinValue: 1
MaxValue: 250
NumReplicas:
Description: 'Number of replicas per shard.'
Type: 'Number'
Default: 2
MinValue: 0
MaxValue: 5
CPUUtilizationThreshold:
Description: 'The maximum percentage of CPU usage (set to -1 to disable).'
Type: Number
Default: 80
MinValue: -1
MaxValue: 100
DatabaseMemoryUsagePercentageThreshold:
Description: 'The maximum percentage of memory usage (set to -1 to disable).'
Type: Number
Default: 90
MinValue: -1
MaxValue: 100
SwapUsageThreshold:
Description: 'The maximum bytes of swap usage (set to -1 to disable).'
Type: Number
Default: 67108864 # 64 MB in Bytes
MinValue: -1
EvictionsThreshold:
Description: 'The maximum number of evictions (set to -1 to disable).'
Type: Number
Default: 1000
MinValue: -1
ReplicationLagThreshold:
Description: 'The maximum seconds of replication lag (set to -1 to disable).'
Type: Number
Default: 30
MinValue: -1
PrivateSubnet1:
Description: Environment Param Name
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/vpc/privatesubnet1aid'
PrivateSubnet2:
Description: Environment Param Name
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/vpc/privatesubnet2aid'
PrivateSubnet3:
Description: Environment Param Name
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/vpc/privatesubnet3aid'
VPC:
Description: vpc id parameter
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/vpc/vpcid'
LambdaSecurityGroup:
Description: Lambda function security group
Type: AWS::SSM::Parameter::Value<String>
Default: '/delta/sample/lambdafunc/securitygrp'
ProjectName:
Type: String
Default: 'sample-test'
Mappings:
EngineVersionMap:
'7.0':
CacheParameterGroupFamily: redis7
'6.2':
CacheParameterGroupFamily: 'redis6.x'
'6.0':
CacheParameterGroupFamily: 'redis6.x'
'5.0.6':
CacheParameterGroupFamily: 'redis5.0'
Conditions:
HasAutomaticFailoverEnabled: !Not [!Equals [!Ref NumReplicas, 0]]
HasClusterModeEnabled: !Not [!Equals [!Ref NumShards, 1]]
HasClusterModeDisabled: !Not [!Condition HasClusterModeEnabled]
Resources:
AlertTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: !Sub ${ProjectName}-${AccountEnv}
KmsMasterKeyId: 'alias/sample-cmk'
CacheParameterGroup:
Type: 'AWS::ElastiCache::ParameterGroup'
Properties:
CacheParameterGroupFamily: !FindInMap [EngineVersionMap, !Ref EngineVersion, CacheParameterGroupFamily]
Description: !Ref 'AWS::StackName'
Properties: !If [HasClusterModeEnabled, {'cluster-enabled': 'yes'}, {}]
CacheSubnetGroupName:
Type: AWS::ElastiCache::SubnetGroup
Properties:
Description: Redis subnet group
SubnetIds:
- !Ref PrivateSubnet1
- !Ref PrivateSubnet2
- !Ref PrivateSubnet3
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: !Ref VPC
GroupDescription: Enable Redis access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 6379
ToPort: 6379
SourceSecurityGroupId: !Ref LambdaSecurityGroup
Tags:
- Key: Project
Value: !Ref ProjectName
GlobalReplicationGroup:
Type: 'AWS::ElastiCache::GlobalReplicationGroup'
Properties:
AutomaticFailoverEnabled: true
#MultiAZEnabled: !If [HasAutomaticFailoverEnabled, true, false]
CacheNodeType: !Ref CacheNodeType
#CacheParameterGroupName: !Ref CacheParameterGroup
EngineVersion: !Ref EngineVersion
GlobalNodeGroupCount: 1
GlobalReplicationGroupDescription: sample-Redis Globalstore'
GlobalReplicationGroupIdSuffix: sample
Members:
- ReplicationGroupId: !Ref ReplicationGroup
ReplicationGroupRegion: 'us-west-2'
Role: PRIMARY
RegionalConfigurations:
- ReplicationGroupId: !Ref ReplicationGroup
ReplicationGroupRegion: 'us-east-1'
ReplicationGroup:
Type: 'AWS::ElastiCache::ReplicationGroup'
Properties:
ReplicationGroupId: !Sub sample-test-${AccountEnv}
# for prefix please check https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Redis-Global-Datastores-CLI.html
#GlobalReplicationGroupId: sgaui-sample
ReplicationGroupDescription: sample replication group for Redis
AtRestEncryptionEnabled: true
AuthToken: "{{resolve:secretsmanager:sample/redis-cluster/authtoken:SecretString:AuthToken}}"
#AutomaticFailoverEnabled: !If [HasAutomaticFailoverEnabled, true, false]
#MultiAZEnabled: !If [HasAutomaticFailoverEnabled, true, false]
CacheNodeType: !Ref CacheNodeType
CacheParameterGroupName: !Ref CacheParameterGroup
CacheSubnetGroupName: !Ref CacheSubnetGroupName
Engine: redis
EngineVersion: !Ref EngineVersion
NotificationTopicArn: !Ref AlertTopic
NumNodeGroups: !Ref NumShards
ReplicasPerNodeGroup: !Ref NumReplicas
SecurityGroupIds:
- !Ref SecurityGroup
TransitEncryptionEnabled: !Ref TransitEncryption
Tags:
- Key: Project
Value: !Ref ProjectName
UpdatePolicy:
UseOnlineResharding: true