Skip to content

Commit

Permalink
switch to ReplicationGroup for multi AZ support
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbucci committed Apr 1, 2019
1 parent fc70e63 commit 91e107a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# mu-elasticache

Mu-elasticache is an extension [for the devops tool mu](https://github.com/stelligent/mu)

This extension automatically creates an elasticache redis cluster in all of
your specified environments

## Using this Extension

copy these files into your project repo, I like to place these extensions under
the folder "mu", so you would create a new directory called mu/elasticache
to hold these files

then place the following at the bottom of your mu.yml file
```
extensions:
- url: mu/elasticache
```

This is all you need to do to get started.

The following environmental variables can be passed to your application
via mu.yml

```
environment:
REDIS_HOST: ${ElasticacheCluster.PrimaryEndPoint.Address}
REDIS_PORT: ${ElasticacheCluster.PrimaryEndPoint.Port}
```

The following parameters are configurable
NumCacheNodes (default is 2 for Multi AZ failover)
CacheNodeType (default is cache.t2.micro)
AutomaticFailoverEnabled (default is true)
30 changes: 25 additions & 5 deletions service-ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Parameters:
NumCacheNodes:
Type: String
Description: Number of cache nodes
Default: 1
Default: 2
CacheNodeType:
Type: String
Description: The compute and memory capacity of the node(s) in the Redis Cluster
Default: "cache.m3.medium"
Default: "cache.t2.micro"
AllowedValues:
- cache.t2.micro
- cache.t2.small
Expand Down Expand Up @@ -43,6 +43,10 @@ Parameters:
- cache.r3.2xlarge
- cache.r3.4xlarge
- cache.r3.8xlarge
AutomaticFailoverEnabled:
Type: String
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.
Default: "true"

Resources:
ElasticacheSubnetGroup:
Expand Down Expand Up @@ -72,15 +76,31 @@ Resources:
Ref: ServiceSecurityGroup

ElasticacheCluster:
Type: "AWS::ElastiCache::CacheCluster"
Type: "AWS::ElastiCache::ReplicationGroup"
Properties:
Engine: "redis"
CacheNodeType:
Ref: CacheNodeType
NumCacheNodes:
NumCacheClusters:
Ref: NumCacheNodes
CacheSubnetGroupName:
Ref: ElasticacheSubnetGroup
VpcSecurityGroupIds:
AutomaticFailoverEnabled:
Ref: AutomaticFailoverEnabled
ReplicationGroupDescription:
Fn::Sub: ${Namespace}-${ServiceName}-${EnvironmentName}-cache
SecurityGroupIds:
- Fn::ImportValue:
Ref: ServiceSecurityGroup

Outputs:
ElasticacheClusterEndpointAddress:
Description: "Elastic Cache Cluster Endpoint Address"
Value:
Fn::Sub:
${ElasticacheCluster.PrimaryEndPoint.Address}
ElasticacheClusterEndpointPort:
Description: "Elastic Cache Cluster Endpoint Port"
Value:
Fn::Sub:
${ElasticacheCluster.PrimaryEndPoint.Port}

0 comments on commit 91e107a

Please sign in to comment.