Skip to content

Commit 438b5a6

Browse files
authored
Merge pull request #12 from theonestack/feature/snaphot-support
Feature - snapshot support
2 parents 598580e + a3aedeb commit 438b5a6

File tree

8 files changed

+24
-19
lines changed

8 files changed

+24
-19
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

redis.cfhighlander.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515

1616
ComponentParam 'DnsDomain'
1717

18-
if snapshot_restore_type.eql?('native')
19-
ComponentParam 'SnapshotName',
20-
description: 'The name of a snapshot from which to restore data into the new replication group'
21-
elsif snapshot_restore_type.eql?('s3')
22-
ComponentParam 'SnapshotArns', type: 'CommaDelimitedList',
18+
ComponentParam 'SnapshotName', '',
19+
description: 'The name of a snapshot from which to restore data into the new replication group'
20+
21+
ComponentParam 'SnapshotArns', '',
2322
description: 'A list of ARNs that uniquely identify the Redis RDB snapshot files stored in S3'
24-
end if defined? snapshot_restore_type
2523

2624
ComponentParam 'SnapshotRetentionLimit',
2725
description: 'The number of days for which ElastiCache retains automatic snapshots before deleting them.'

redis.cfndsl.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
automatic_failover = external_parameters.fetch(:automatic_failover, true)
8080

8181
Condition('DataTieringEnabled', FnEquals(Ref(:DataTieringEnabled), 'true'))
82+
Condition('NoSnapshotNamEnabled', FnEquals(Ref(:SnapshotName), ''))
83+
Condition('NoSnapshotArnsEnabled', FnEquals(Ref(:SnapshotArns), ''))
8284

8385
engine = external_parameters.fetch(:engine, 'redis')
8486

@@ -111,14 +113,8 @@
111113
NumCacheClusters Ref(:NumCacheClusters)
112114
end
113115

114-
snapshot_restore_type = external_parameters.fetch(:snapshot_restore_type, nil)
115-
116-
if snapshot_restore_type.eql?('native')
117-
SnapshotName Ref(:SnapshotName)
118-
elsif snapshot_restore_type.eql?('s3')
119-
SnapshotArns Ref(:SnapshotArns)
120-
end unless snapshot_restore_type.nil?
121-
116+
SnapshotName FnIf('NoSnapshotNamEnabled', Ref('AWS::NoValue'), Ref(:SnapshotName))
117+
SnapshotArns FnIf('NoSnapshotArnsEnabled', Ref('AWS::NoValue'), FnSplit(",", Ref(:SnapshotArns)))
122118
SnapshotRetentionLimit Ref(:SnapshotRetentionLimit)
123119

124120
SnapshotWindow snapshot_window unless snapshot_window.nil?

spec/cache-cluster_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
context 'cftest' do
66
it 'compiles test' do
7-
expect(system("cfhighlander cftest --tests tests/cache-cluster.test.yaml")).to be_truthy
7+
expect(system("cfhighlander cftest #{@validate} --tests tests/cache-cluster.test.yaml")).to be_truthy
88
end
99
end
1010

@@ -27,6 +27,8 @@
2727
"NumCacheClusters" => {"Ref"=>"NumCacheClusters"},
2828
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
2929
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
30+
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
31+
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
3032
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
3133
"Tags" => [
3234
{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}},

spec/clustered_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
context 'cftest' do
66
it 'compiles test' do
7-
expect(system("cfhighlander cftest --tests tests/clustered.test.yaml")).to be_truthy
7+
expect(system("cfhighlander cftest #{@validate} --tests tests/clustered.test.yaml")).to be_truthy
88
end
99
end
1010

@@ -30,6 +30,8 @@
3030
"ReplicasPerNodeGroup" => {"Ref"=>"ReplicasPerNodeGroup"},
3131
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
3232
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
33+
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
34+
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
3335
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
3436
"SnapshotWindow" => "00:30-02:30",
3537
"Tags" => [

spec/default_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
context 'cftest' do
66
it 'compiles test' do
7-
expect(system("cfhighlander cftest --tests tests/default.test.yaml")).to be_truthy
7+
expect(system("cfhighlander cftest #{@validate} --tests tests/default.test.yaml")).to be_truthy
88
end
99
end
1010

@@ -28,6 +28,8 @@
2828
"ReplicasPerNodeGroup" => {"Ref"=>"ReplicasPerNodeGroup"},
2929
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
3030
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
31+
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
32+
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
3133
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
3234
"Tags" => [
3335
{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}},

spec/node-group_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
context 'cftest' do
66
it 'compiles test' do
7-
expect(system("cfhighlander cftest --tests tests/node-group.test.yaml")).to be_truthy
7+
expect(system("cfhighlander cftest #{@validate} --tests tests/node-group.test.yaml")).to be_truthy
88
end
99
end
1010

@@ -28,6 +28,8 @@
2828
"ReplicasPerNodeGroup" => {"Ref"=>"ReplicasPerNodeGroup"},
2929
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
3030
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
31+
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
32+
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
3133
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
3234
"Tags" => [
3335
{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}},

spec/non-clustered_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
context 'cftest' do
66
it 'compiles test' do
7-
expect(system("cfhighlander cftest --tests tests/non-clustered.test.yaml")).to be_truthy
7+
expect(system("cfhighlander cftest #{@validate} --tests tests/non-clustered.test.yaml")).to be_truthy
88
end
99
end
1010

@@ -28,6 +28,8 @@
2828
"ReplicasPerNodeGroup" => {"Ref"=>"ReplicasPerNodeGroup"},
2929
"ReplicationGroupDescription" => {"Fn::Sub"=>"${EnvironmentName}-redis"},
3030
"SecurityGroupIds" => [{"Ref"=>"SecurityGroupRedis"}],
31+
"SnapshotArns" => {"Fn::If" => ["NoSnapshotArnsEnabled", {"Ref" => "AWS::NoValue"}, {"Fn::Split" => [",", {"Ref" => "SnapshotArns"}]}]},
32+
"SnapshotName" => {"Fn::If" => ["NoSnapshotNamEnabled", {"Ref" => "AWS::NoValue"}, {"Ref" => "SnapshotName"}]},
3133
"SnapshotRetentionLimit" => {"Ref"=>"SnapshotRetentionLimit"},
3234
"Tags" => [
3335
{"Key"=>"Name", "Value"=>{"Fn::Sub"=>"${EnvironmentName}-redis"}},

0 commit comments

Comments
 (0)