Skip to content

Commit 91e107a

Browse files
committed
switch to ReplicationGroup for multi AZ support
1 parent fc70e63 commit 91e107a

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
11
# mu-elasticache
2+
3+
Mu-elasticache is an extension [for the devops tool mu](https://github.com/stelligent/mu)
4+
5+
This extension automatically creates an elasticache redis cluster in all of
6+
your specified environments
7+
8+
## Using this Extension
9+
10+
copy these files into your project repo, I like to place these extensions under
11+
the folder "mu", so you would create a new directory called mu/elasticache
12+
to hold these files
13+
14+
then place the following at the bottom of your mu.yml file
15+
```
16+
extensions:
17+
- url: mu/elasticache
18+
```
19+
20+
This is all you need to do to get started.
21+
22+
The following environmental variables can be passed to your application
23+
via mu.yml
24+
25+
```
26+
environment:
27+
REDIS_HOST: ${ElasticacheCluster.PrimaryEndPoint.Address}
28+
REDIS_PORT: ${ElasticacheCluster.PrimaryEndPoint.Port}
29+
```
30+
31+
The following parameters are configurable
32+
NumCacheNodes (default is 2 for Multi AZ failover)
33+
CacheNodeType (default is cache.t2.micro)
34+
AutomaticFailoverEnabled (default is true)

service-ecs.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Parameters:
22
NumCacheNodes:
33
Type: String
44
Description: Number of cache nodes
5-
Default: 1
5+
Default: 2
66
CacheNodeType:
77
Type: String
88
Description: The compute and memory capacity of the node(s) in the Redis Cluster
9-
Default: "cache.m3.medium"
9+
Default: "cache.t2.micro"
1010
AllowedValues:
1111
- cache.t2.micro
1212
- cache.t2.small
@@ -43,6 +43,10 @@ Parameters:
4343
- cache.r3.2xlarge
4444
- cache.r3.4xlarge
4545
- cache.r3.8xlarge
46+
AutomaticFailoverEnabled:
47+
Type: String
48+
Description: Indicates whether Multi-AZ is enabled. When Multi-AZ is enabled, a read-only replica is automatically promoted to a read-write primary cluster if the existing primary cluster fails.
49+
Default: "true"
4650

4751
Resources:
4852
ElasticacheSubnetGroup:
@@ -72,15 +76,31 @@ Resources:
7276
Ref: ServiceSecurityGroup
7377

7478
ElasticacheCluster:
75-
Type: "AWS::ElastiCache::CacheCluster"
79+
Type: "AWS::ElastiCache::ReplicationGroup"
7680
Properties:
7781
Engine: "redis"
7882
CacheNodeType:
7983
Ref: CacheNodeType
80-
NumCacheNodes:
84+
NumCacheClusters:
8185
Ref: NumCacheNodes
8286
CacheSubnetGroupName:
8387
Ref: ElasticacheSubnetGroup
84-
VpcSecurityGroupIds:
88+
AutomaticFailoverEnabled:
89+
Ref: AutomaticFailoverEnabled
90+
ReplicationGroupDescription:
91+
Fn::Sub: ${Namespace}-${ServiceName}-${EnvironmentName}-cache
92+
SecurityGroupIds:
8593
- Fn::ImportValue:
8694
Ref: ServiceSecurityGroup
95+
96+
Outputs:
97+
ElasticacheClusterEndpointAddress:
98+
Description: "Elastic Cache Cluster Endpoint Address"
99+
Value:
100+
Fn::Sub:
101+
${ElasticacheCluster.PrimaryEndPoint.Address}
102+
ElasticacheClusterEndpointPort:
103+
Description: "Elastic Cache Cluster Endpoint Port"
104+
Value:
105+
Fn::Sub:
106+
${ElasticacheCluster.PrimaryEndPoint.Port}

0 commit comments

Comments
 (0)