cfndsl 1.0.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +18 -3
- data/.travis.yml +1 -1
- data/CHANGELOG.md +215 -41
- data/README.md +9 -11
- data/Rakefile +3 -1
- data/cfndsl.gemspec +2 -2
- data/lib/cfndsl/aws/patches/500_BadTagsv13.0.0_patch.json +51 -0
- data/lib/cfndsl/aws/patches/500_BadTagsv16.2.0_patch.json +23 -0
- data/lib/cfndsl/aws/patches/900_SageMakerTags_patch.json +41 -0
- data/lib/cfndsl/aws/resource_specification.json +4528 -3459
- data/lib/cfndsl/cfnlego/cloudformation.rb +1 -1
- data/lib/cfndsl/cloudformation.rb +3 -2
- data/lib/cfndsl/globals.rb +1 -0
- data/lib/cfndsl/jsonable.rb +7 -6
- data/lib/cfndsl/orchestration_template.rb +3 -5
- data/lib/cfndsl/plurals.rb +2 -2
- data/lib/cfndsl/rake_task.rb +6 -6
- data/lib/cfndsl/ref_check.rb +2 -2
- data/lib/cfndsl/resources.rb +18 -1
- data/lib/cfndsl/runner.rb +2 -4
- data/lib/cfndsl/specification.rb +11 -13
- data/lib/cfndsl/types.rb +11 -7
- data/lib/cfndsl/version.rb +1 -1
- data/lib/deep_merge/core.rb +9 -8
- data/sample/vpc_example.rb +3 -3
- data/sample/vpc_with_vpn_example.rb +3 -3
- data/spec/cfndsl_spec.rb +20 -0
- data/spec/cli_spec.rb +2 -0
- data/spec/cloud_formation_template_spec.rb +34 -0
- data/spec/support/shared_examples/orchestration_template.rb +7 -0
- data/spec/types_definition_spec.rb +3 -2
- metadata +9 -7
data/spec/cli_spec.rb
CHANGED
@@ -36,7 +36,9 @@ describe 'cfndsl', type: :aruba do
|
|
36
36
|
before(:each) { write_file('template.rb', template_content) }
|
37
37
|
|
38
38
|
# The known working version is the embedded version
|
39
|
+
# rubocop:disable Lint/ConstantDefinitionInBlock
|
39
40
|
WORKING_SPEC_VERSION = JSON.parse(File.read(CfnDsl::LOCAL_SPEC_FILE))['ResourceSpecificationVersion']
|
41
|
+
# rubocop:enable Lint/ConstantDefinitionInBlock
|
40
42
|
|
41
43
|
context "cfndsl -u #{WORKING_SPEC_VERSION}" do
|
42
44
|
it 'updates the specification file' do
|
@@ -40,10 +40,31 @@ describe CfnDsl::CloudFormationTemplate do
|
|
40
40
|
expect(subject.validate).to equal(subject)
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'returns self if there are valid Fn::Sub references to other resources' do
|
44
|
+
tr = subject.Resource(:TestResource)
|
45
|
+
tr.Type('Custom-TestType')
|
46
|
+
tr.Property(:AProperty, tr.FnSub('prefix ${TestResource2}suffix'))
|
47
|
+
|
48
|
+
t2 = subject.Resource('TestResource2')
|
49
|
+
t2.Type('Custom-TestType')
|
50
|
+
expect(subject.validate).to equal(subject)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns self if there are valid Fn::Sub references to other resource attributes' do
|
54
|
+
tr = subject.Resource(:TestResource)
|
55
|
+
tr.Type('Custom-TestType')
|
56
|
+
tr.Property(:AProperty, tr.FnSub('prefix ${TestResource2.AnAttribute}suffix'))
|
57
|
+
|
58
|
+
t2 = subject.Resource('TestResource2')
|
59
|
+
t2.Type('Custom-TestType')
|
60
|
+
expect(subject.validate).to equal(subject)
|
61
|
+
end
|
62
|
+
|
43
63
|
it 'returns self if there are valid DependsOn to other resources' do
|
44
64
|
tr = subject.Resource(:TestResource)
|
45
65
|
tr.Type('Custom-TestType')
|
46
66
|
tr.DependsOn(:TestResource2)
|
67
|
+
tr.DependsOn(:TestResource2)
|
47
68
|
|
48
69
|
t2 = subject.Resource('TestResource2')
|
49
70
|
t2.Type('Custom-TestType')
|
@@ -119,6 +140,13 @@ describe CfnDsl::CloudFormationTemplate do
|
|
119
140
|
expect { subject.validate }.to raise_error(CfnDsl::Error, /TestResource.*itself/i)
|
120
141
|
end
|
121
142
|
|
143
|
+
it 'raises CfnDsl::Error if a resourcs references itself in Fn::Sub attribute expression' do
|
144
|
+
tr = subject.Resource(:TestResource)
|
145
|
+
tr.Type('Custom-TestType')
|
146
|
+
tr.Property(:AProperty, tr.FnSub('${TestResource.attr}'))
|
147
|
+
expect { subject.validate }.to raise_error(CfnDsl::Error, /TestResource.*itself/i)
|
148
|
+
end
|
149
|
+
|
122
150
|
it 'raises CfnDsl::Error if there are cyclic DependsOn references' do
|
123
151
|
tr = subject.Resource(:ResourceOne)
|
124
152
|
tr.Type('Custom-TestType')
|
@@ -211,6 +239,12 @@ describe CfnDsl::CloudFormationTemplate do
|
|
211
239
|
expect(subject.validate).to equal(subject)
|
212
240
|
end
|
213
241
|
|
242
|
+
it 'returns self if there are valid Fn::Sub references to resource attributes' do
|
243
|
+
subject.Resource(:TestResource)
|
244
|
+
subject.Output('TestResourceOutput').Value(subject.FnSub('prefix ${TestResource.attr}suffix'))
|
245
|
+
expect(subject.validate).to equal(subject)
|
246
|
+
end
|
247
|
+
|
214
248
|
it 'raises CfnDsl::Error if references a non existent condition' do
|
215
249
|
subject.Output(:TestOutput).Condition('NoCondition')
|
216
250
|
expect { subject.validate }.to raise_error(CfnDsl::Error, /TestOutput.*NoCondition/)
|
@@ -102,6 +102,13 @@ shared_examples 'an orchestration template' do
|
|
102
102
|
expect(plural_value).to eq([{ foo: 'bar' }])
|
103
103
|
end
|
104
104
|
|
105
|
+
it 'allows array returning function for otherwise array value when singular name == plural name' do
|
106
|
+
security_group = described_class.type_module.const_get('AWS_EC2_SecurityGroup').new
|
107
|
+
security_group.Property('SecurityGroupIngress', security_group.FnFindInMap('x', 'y', 'z'))
|
108
|
+
plural_value = security_group.instance_variable_get('@Properties')['SecurityGroupIngress'].value
|
109
|
+
expect(plural_value.to_json).to eql('{"Fn::FindInMap":["x","y","z"]}')
|
110
|
+
end
|
111
|
+
|
105
112
|
it 'sets the type of each resource correctly' do
|
106
113
|
ec2_instance = subject.EC2_Instance(:foo)
|
107
114
|
expect(ec2_instance.instance_variable_get('@Type')).to eq('AWS::EC2::Instance')
|
@@ -27,9 +27,10 @@ RSpec.describe 'Type Definitions' do
|
|
27
27
|
it "#{name} has all property types defined" do
|
28
28
|
type = type['Properties'] if type.is_a?(Hash) && type.key?('Properties')
|
29
29
|
type = type.first if type.is_a?(Array)
|
30
|
-
|
30
|
+
case type
|
31
|
+
when String
|
31
32
|
expect(types).to have_key(type)
|
32
|
-
|
33
|
+
when Hash
|
33
34
|
type.values.flatten.each { |t| expect(types).to have_key(t) }
|
34
35
|
else
|
35
36
|
raise "A defined type should only be of the form String, Array or Hash, got #{type.class}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfndsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-01-03 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '2.
|
22
|
+
version: '2.2'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: hana
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +70,8 @@ files:
|
|
70
70
|
- lib/cfndsl/aws/patches/000_sam.spec.json
|
71
71
|
- lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json
|
72
72
|
- lib/cfndsl/aws/patches/200_Scrutinies_patch.json
|
73
|
+
- lib/cfndsl/aws/patches/500_BadTagsv13.0.0_patch.json
|
74
|
+
- lib/cfndsl/aws/patches/500_BadTagsv16.2.0_patch.json
|
73
75
|
- lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json
|
74
76
|
- lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json
|
75
77
|
- lib/cfndsl/aws/patches/500_NetworkAclEntry_patch.json
|
@@ -82,6 +84,7 @@ files:
|
|
82
84
|
- lib/cfndsl/aws/patches/600_RefKinds_patch.json
|
83
85
|
- lib/cfndsl/aws/patches/700_SAM_Serverless_Function_InlineCode_patch.json
|
84
86
|
- lib/cfndsl/aws/patches/800_List_types_patch.json
|
87
|
+
- lib/cfndsl/aws/patches/900_SageMakerTags_patch.json
|
85
88
|
- lib/cfndsl/aws/resource_specification.json
|
86
89
|
- lib/cfndsl/aws/types.rb
|
87
90
|
- lib/cfndsl/aws/types.yaml
|
@@ -183,15 +186,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
186
|
requirements:
|
184
187
|
- - "~>"
|
185
188
|
- !ruby/object:Gem::Version
|
186
|
-
version: '2.
|
189
|
+
version: '2.7'
|
187
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
191
|
requirements:
|
189
192
|
- - ">="
|
190
193
|
- !ruby/object:Gem::Version
|
191
194
|
version: '0'
|
192
195
|
requirements: []
|
193
|
-
|
194
|
-
rubygems_version: 2.7.7
|
196
|
+
rubygems_version: 3.0.8
|
195
197
|
signing_key:
|
196
198
|
specification_version: 4
|
197
199
|
summary: AWS Cloudformation DSL
|