Skip to content

Commit 5a2bd13

Browse files
author
guslington
committed
initial
0 parents  commit 5a2bd13

File tree

8 files changed

+262
-0
lines changed

8 files changed

+262
-0
lines changed

.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
*.gem
2+
*.rbc
3+
/.config
4+
/coverage/
5+
/InstalledFiles
6+
/pkg/
7+
/spec/reports/
8+
/spec/examples.txt
9+
/test/tmp/
10+
/test/version_tmp/
11+
/tmp/
12+
13+
# Used by dotenv library to load environment variables.
14+
# .env
15+
16+
## Specific to RubyMotion:
17+
.dat*
18+
.repl_history
19+
build/
20+
*.bridgesupport
21+
build-iPhoneOS/
22+
build-iPhoneSimulator/
23+
24+
## Specific to RubyMotion (use of CocoaPods):
25+
#
26+
# We recommend against adding the Pods directory to your .gitignore. However
27+
# you should judge for yourself, the pros and cons are mentioned at:
28+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29+
#
30+
# vendor/Pods/
31+
32+
## Documentation cache and generated files:
33+
/.yardoc/
34+
/_yardoc/
35+
/doc/
36+
/rdoc/
37+
38+
## Environment normalization:
39+
/.bundle/
40+
/vendor/bundle
41+
/lib/bundler/man/
42+
43+
# for a library or gem, you might want to ignore these files since the code is
44+
# intended to run in multiple environments; otherwise, check them in:
45+
# Gemfile.lock
46+
# .ruby-version
47+
# .ruby-gemset
48+
49+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50+
.rvmrc
51+
52+
out/

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: ruby
2+
rvm:
3+
- 2.3
4+
script:
5+
- gem install cfhighlander
6+
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then cfhighlander cfcompile ; else cfhighlander cfcompile --validate; fi

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 theonestack
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
![build-status](https://travis-ci.com/theonestack/hl-component-elasticache-redis.svg?branch=master)
2+
3+
### Cfhighlander ElastiCache Redis component
4+
5+
Default Family: `redis4.0`
6+
7+
```bash
8+
9+
# install highlander gem
10+
$ gem install cfhighlander
11+
12+
# build and validate standalone component
13+
$ cfhighlander cfcompile --validate elasticache-redis
14+
15+
```
16+
17+
18+
### Parameters
19+
20+
TBD
21+
22+
### Configuration options
23+
24+
TBD
25+
26+
### Outputs
27+
28+
TBD

redis.cfhighlander.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CfhighlanderTemplate do
2+
Name 'ElastiCacheRedis'
3+
Description "#{component_name} - #{component_version}"
4+
ComponentVersion component_version
5+
6+
DependsOn 'vpc'
7+
8+
Parameters do
9+
ComponentParam 'VPCId'
10+
ComponentParam 'StackOctet', isGlobal: true
11+
ComponentParam 'EnvironmentName', 'dev', isGlobal: true
12+
ComponentParam 'EnvironmentType', 'development', isGlobal: true, allowedValues: ['development', 'production']
13+
ComponentParam 'DnsDomain'
14+
ComponentParam 'CacheInstanceType'
15+
16+
ComponentParam 'S3Snapshot', '' if restore_from_s3
17+
ComponentParam 'Snapshot', '' if restore_from_snapshot
18+
19+
ComponentParam 'CacheClusters', 1, allowedValues: [1,2,3,4,5,6]
20+
ComponentParam 'Cluster', 'false', allowedValues: ['true','false']
21+
ComponentParam 'NumNodeGroups', 1
22+
ComponentParam 'ReplicasPerNodeGroup', 0, allowedValues: [0,1,2,3,4,5]
23+
24+
MappingParam 'SnapshotRetentionLimit', 0 do
25+
map 'EnvironmentType'
26+
attribute 'SnapshotRetentionLimit'
27+
end
28+
29+
maximum_availability_zones.times do |az|
30+
ComponentParam "SubnetCache#{az}"
31+
end
32+
end
33+
end

redis.cfndsl.rb

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
CloudFormation do
2+
3+
Condition(:FailOver, FnNot(FnEquals(Ref(:CacheClusters), '1')))
4+
Condition(:Cluster, FnEquals(Ref(:Cluster), 'true'))
5+
az_conditions_resources('SubnetCache', maximum_availability_zones)
6+
7+
tags = []
8+
tags << { Key: 'Environment', Value: Ref(:EnvironmentName) }
9+
tags << { Key: 'EnvironmentType', Value: Ref(:EnvironmentType) }
10+
11+
extra_tags.each { |key,value| tags << { Key: key, Value: value } } if defined? extra_tags
12+
13+
EC2_SecurityGroup(:SecurityGroupRedis) do
14+
VpcId Ref('VPCId')
15+
GroupDescription FnJoin(' ', [ Ref(:EnvironmentName), component_name, 'security group' ])
16+
SecurityGroupIngress sg_create_rules(security_groups, ip_blocks)
17+
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), component_name, 'security-group' ])}]
18+
end
19+
20+
ElastiCache_SubnetGroup(:RedisSubnetGroup) {
21+
Description FnJoin('',[ Ref(:EnvironmentName), 'redis parameter group'] )
22+
SubnetIds az_conditional_resources('SubnetCache', maximum_availability_zones)
23+
}
24+
25+
ElastiCache_ParameterGroup(:RedisParameterGroup) {
26+
CacheParameterGroupFamily family
27+
Description FnJoin(' ',[ Ref(:EnvironmentName), component_name, 'parameter group'] )
28+
Properties parameters if defined? parameters
29+
}
30+
31+
cluster_parameters = { 'cluster-enabled': 'yes' }
32+
cluster_parameters.merge!(parameters) if defined? parameters
33+
34+
ElastiCache_ParameterGroup(:RedisClusterParameterGroup) {
35+
CacheParameterGroupFamily family
36+
Description FnJoin(' ',[ Ref(:EnvironmentName), component_name, 'parameter group'] )
37+
Properties cluster_parameters
38+
}
39+
40+
ElastiCache_ReplicationGroup(:RedisReplicationGroup) {
41+
DependsOn ["RedisSubnetGroup"]
42+
43+
ReplicationGroupDescription FnJoin(' ',[ Ref(:EnvironmentName), component_name, 'replication group'] )
44+
45+
Engine 'redis'
46+
EngineVersion engine_version if defined? engine_version
47+
AutoMinorVersionUpgrade minor_upgrade || true
48+
Port redis_port if defined? redis_port
49+
CacheNodeType Ref(:CacheInstanceType)
50+
CacheParameterGroupName FnIf(:Cluster, Ref(:RedisClusterParameterGroup), Ref(:RedisParameterGroup))
51+
CacheSubnetGroupName Ref(:RedisSubnetGroup)
52+
SecurityGroupIds [ Ref(:SecurityGroupRedis) ]
53+
54+
Property('AtRestEncryptionEnabled', encrypt) if defined? encrypt
55+
56+
# AuthToken 'String'
57+
# TransitEncryptionEnabled true
58+
59+
AutomaticFailoverEnabled FnIf(:FailOver, true, false)
60+
NumCacheClusters Ref(:CacheClusters)
61+
62+
NumNodeGroups FnIf(:Cluster, Ref(:NumNodeGroups), 1)
63+
ReplicasPerNodeGroup FnIf(:Cluster, Ref(:ReplicasPerNodeGroup), 0)
64+
65+
SnapshotArns [ Ref(:S3Snapshot) ] if restore_from_s3
66+
SnapshotName Ref(:Snapshot) if restore_from_snapshot
67+
SnapshotWindow snapshot_window if defined? snapshot_window
68+
SnapshotRetentionLimit Ref(:SnapshotRetentionLimit)
69+
PreferredMaintenanceWindow maintenance_window if defined? maintenance_window
70+
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), component_name, 'cache-cluster' ]) }]
71+
}
72+
73+
record = (defined? dns_record ? "#{dns_record}" : 'redis')
74+
75+
Route53_RecordSet(:RedisHostRecord) {
76+
HostedZoneName FnJoin('', [ Ref(:EnvironmentName), '.', Ref(:DnsDomain), '.'])
77+
Name FnJoin('', [record, '.', Ref(:EnvironmentName), '.', Ref(:DnsDomain), '.'])
78+
Type 'CNAME'
79+
TTL '60'
80+
ResourceRecords [ FnGetAtt(:RedisReplicationGroup,'PrimaryEndPoint.Address') ]
81+
}
82+
83+
end

redis.config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
maximum_availability_zones: 5
2+
component_version: 1.0.0
3+
4+
# Restore
5+
restore_from_s3: false
6+
restore_from_snapshot: false
7+
8+
# engine_version: 4.0.10
9+
family: redis4.0
10+
11+
minor_upgrade: true
12+
encrypt: true
13+
14+
# maintenance_window: sun:03:25-sun:05:30
15+
# snapshot_window: 00:30-02:30
16+
17+
parameters:
18+
maxmemory-policy: allkeys-lru
19+
#
20+
# redis_port: 6379
21+
22+
security_groups:
23+
-
24+
rules:
25+
-
26+
IpProtocol: tcp
27+
FromPort: 6379
28+
ToPort: 6379
29+
ips:
30+
- stack
31+
32+
ip_blocks:
33+
local:
34+
- 169.254.169.254/32

redis.mappings.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
EnvironmentType:
2+
production:
3+
SnapshotRetentionLimit: 14
4+
development:
5+
SnapshotRetentionLimit: 0

0 commit comments

Comments
 (0)