Skip to content

Commit c5077c0

Browse files
feat: support custom cache parameter group (#12)
1 parent 40983d2 commit c5077c0

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Resources:
3434
SnapshotName: '' # optional
3535
NumShards: '1' # optional
3636
NumReplicas: '1' # optional
37+
CacheParameterGroupName: '' # optional
3738
TemplateURL: './node_modules/@cfn-modules/elasticache-redis/module.yml'
3839
```
3940

@@ -149,6 +150,13 @@ none
149150
<td>no</td>
150151
<td>[0-5]</td>
151152
</tr>
153+
<tr>
154+
<td>CacheParameterGroupName</td>
155+
<td>Name of a cache parameter group</td>
156+
<td></td>
157+
<td>no</td>
158+
<td></td>
159+
</tr>
152160
</tbody>
153161
</table>
154162

module.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,19 @@ Parameters:
8282
Default: 1
8383
MinValue: 0
8484
MaxValue: 5
85+
CacheParameterGroupName:
86+
Description: 'Optional name of a cache parameter group.'
87+
Type: 'String'
88+
Default: ''
8589
Conditions:
8690
HasAlertingModule: !Not [!Equals [!Ref AlertingModule, '']]
8791
HasBastionModule: !Not [!Equals [!Ref BastionModule, '']]
8892
HasKmsKeyModule: !Not [!Equals [!Ref KmsKeyModule, '']]
8993
HasAuthToken: !Not [!Equals [!Ref AuthToken, '']]
9094
HasSnapshotName: !Not [!Equals [!Ref SnapshotName, '']]
9195
HasAutomaticFailoverEnabled: !Not [!Equals [!Ref NumReplicas, 0]]
96+
HasCacheParameterGroupName: !Not [!Equals [!Ref CacheParameterGroupName, '']]
97+
HasNotCacheParameterGroupName: !Not [!Condition HasCacheParameterGroupName]
9298
Mappings:
9399
EngineVersionMap:
94100
'5.0.5':
@@ -101,6 +107,7 @@ Mappings:
101107
CacheParameterGroupFamily: 'redis6.x'
102108
Resources:
103109
CacheParameterGroup:
110+
Condition: HasNotCacheParameterGroupName
104111
Type: 'AWS::ElastiCache::ParameterGroup'
105112
Properties:
106113
CacheParameterGroupFamily: !FindInMap [EngineVersionMap, !Ref EngineVersion, CacheParameterGroupFamily]
@@ -140,7 +147,7 @@ Resources:
140147
AuthToken: !If [HasAuthToken, !Ref AuthToken, !Ref 'AWS::NoValue']
141148
AutomaticFailoverEnabled: !If [HasAutomaticFailoverEnabled, true, false]
142149
CacheNodeType: !Ref CacheNodeType
143-
CacheParameterGroupName: !Ref CacheParameterGroup
150+
CacheParameterGroupName: !If [HasCacheParameterGroupName, !Ref CacheParameterGroupName, !Ref CacheParameterGroup]
144151
CacheSubnetGroupName: !Ref CacheSubnetGroupName
145152
Engine: redis
146153
EngineVersion: !Ref EngineVersion
@@ -313,7 +320,7 @@ Outputs:
313320
ModuleId:
314321
Value: 'elasticache-redis'
315322
ModuleVersion:
316-
Value: '1.0.1'
323+
Value: '1.1.0'
317324
StackName:
318325
Value: !Ref 'AWS::StackName'
319326
Name:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cfn-modules/elasticache-redis",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "ElastiCache redis cluster with secure firewall configuration, encryption, multi AZ, backup enabled, and alerting",
55
"author": "Michael Wittig <[email protected]>",
66
"license": "Apache-2.0",

test/cacheParameterGroupName.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const test = require('ava');
2+
const cfntest = require('@cfn-modules/test');
3+
4+
test.serial('cacheParameterGroupName', async t => {
5+
const stackName = cfntest.stackName();
6+
try {
7+
t.log(await cfntest.createStack(`${__dirname}/cacheParameterGroupName.yml`, stackName, {}));
8+
// what could we test here?
9+
} finally {
10+
t.log(await cfntest.deleteStack(stackName));
11+
t.pass();
12+
}
13+
});

test/cacheParameterGroupName.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
AWSTemplateFormatVersion: '2010-09-09'
3+
Description: 'cfn-modules test'
4+
Resources:
5+
Vpc:
6+
Type: 'AWS::CloudFormation::Stack'
7+
Properties:
8+
Parameters:
9+
S3Endpoint: 'false' # speed up the test
10+
DynamoDBEndpoint: 'false' # speed up the test
11+
FlowLog: 'false' # speed up the test
12+
NatGateways: 'false' # speed up the test
13+
TemplateURL: './node_modules/@cfn-modules/vpc/module.yml'
14+
ClientSg:
15+
Type: 'AWS::CloudFormation::Stack'
16+
Properties:
17+
Parameters:
18+
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
19+
TemplateURL: './node_modules/@cfn-modules/client-sg/module.yml'
20+
CacheParameterGroup:
21+
Type: 'AWS::ElastiCache::ParameterGroup'
22+
Properties:
23+
CacheParameterGroupFamily: 'redis6.x'
24+
Description: !Ref 'AWS::StackName'
25+
Properties:
26+
'maxmemory-policy': 'noeviction'
27+
Cache:
28+
Type: 'AWS::CloudFormation::Stack'
29+
Properties:
30+
Parameters:
31+
VpcModule: !GetAtt 'Vpc.Outputs.StackName'
32+
ClientSgModule: !GetAtt 'ClientSg.Outputs.StackName'
33+
EngineVersion: '6.2'
34+
CacheParameterGroupName: !Ref CacheParameterGroup
35+
TemplateURL: './node_modules/@cfn-modules/elasticache-redis/module.yml'

0 commit comments

Comments
 (0)