cfndsl 1.1.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c11f50695d1e13909473489585ada3f4f3e82817d1b79819c26cc3301dd74dc2
4
- data.tar.gz: f944c74fdb59b4a52677a7816a4e65b97ad39ba8046124cbafeda3fe311a7304
3
+ metadata.gz: 903e5bbbe4c6bf5e02d3b3a9d6ca8582c0e2836d136347bbe7afd6baf7b2b4d5
4
+ data.tar.gz: cd8e5b739f8c2ef469cfa67a17ec90ab736aab0381e69f65b2fd9d7ad1a1e460
5
5
  SHA512:
6
- metadata.gz: ff62869d9f35a74c25298669cfb3c36a1b9512a4b30991d4e374278eb6bbde19292f20c31fd079a6751b6db71728c4501f425b45f37350750382aec5f54b9dbf
7
- data.tar.gz: a2db5440ca6d3dfce93f8cbc9cfc92bf2c98be149cd63476d6895bcb93e310f0b728a6dc3a90bc342b7915bd0b9a1643a1b6e6027ec4ec5097564f209e94d62c
6
+ metadata.gz: 023716cdcc14ff56fac40cfd7851ffb706969886147b42fe9ba3d1b2dee0749c1e819bb8507a4e3671549d15edb426c8022e80e00c90933cacc8ffbfc2ae8967
7
+ data.tar.gz: 12f33663d5de5405f109e7ad95d0b0235b35e19513af12081fb175887a5f86b0ae6652d3c3cd44415dce67a30dcebd309b41e82d091119eea1939fdaf5e496f0
@@ -1,8 +1,36 @@
1
1
  # Changelog
2
2
 
3
- ## [1.1.1](https://github.com/cfndsl/cfndsl/tree/1.1.1) (2020-06-02)
3
+ ## [1.2.0](https://github.com/cfndsl/cfndsl/tree/1.2.0) (2020-07-30)
4
4
 
5
- [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v1.1.0...1.1.1)
5
+ [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v1.1.1...1.2.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Support for Fn::EachMemberEquals, Fn::EachMemberIn, Fn::RefAll, Fn::ValueOf , Fn::ValueOfAll [\#250](https://github.com/cfndsl/cfndsl/issues/250)
10
+ - Handle Serialization Generically [\#248](https://github.com/cfndsl/cfndsl/issues/248)
11
+ - Clarify Functions [\#232](https://github.com/cfndsl/cfndsl/issues/232)
12
+ - Support for rendering nested stacks [\#118](https://github.com/cfndsl/cfndsl/issues/118)
13
+ - Config driven template generation [\#117](https://github.com/cfndsl/cfndsl/issues/117)
14
+ - Unintended side effectos of PR \#64 - Need better error messages for ambiguous resources. [\#68](https://github.com/cfndsl/cfndsl/issues/68)
15
+ - DependsOn should be constructive [\#63](https://github.com/cfndsl/cfndsl/issues/63)
16
+
17
+ **Closed issues:**
18
+
19
+ - SecurityGroupIngress is always an array - 1.1.1 [\#460](https://github.com/cfndsl/cfndsl/issues/460)
20
+ - CloudFrontOriginAccessIdentity is an undefined method [\#448](https://github.com/cfndsl/cfndsl/issues/448)
21
+ - Suggested way of splitting code to multiple files? [\#259](https://github.com/cfndsl/cfndsl/issues/259)
22
+ - Move AWS Types to ruby Contracts for better and more flexible validation? [\#222](https://github.com/cfndsl/cfndsl/issues/222)
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Support composeable DependsOn [\#465](https://github.com/cfndsl/cfndsl/pull/465) ([lwoggardner](https://github.com/lwoggardner))
27
+ - test workaround for \#460 [\#463](https://github.com/cfndsl/cfndsl/pull/463) ([lwoggardner](https://github.com/lwoggardner))
28
+ - Bring up to date [\#462](https://github.com/cfndsl/cfndsl/pull/462) ([lwoggardner](https://github.com/lwoggardner))
29
+ - Update cfndsl raison d'être [\#461](https://github.com/cfndsl/cfndsl/pull/461) ([lwoggardner](https://github.com/lwoggardner))
30
+
31
+ ## [v1.1.1](https://github.com/cfndsl/cfndsl/tree/v1.1.1) (2020-06-02)
32
+
33
+ [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v1.1.0...v1.1.1)
6
34
 
7
35
  **Merged pull requests:**
8
36
 
@@ -950,10 +978,6 @@
950
978
 
951
979
  [Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.8.0...v0.8.1)
952
980
 
953
- **Implemented enhancements:**
954
-
955
- - Use as\_json instead of to\_json [\#157](https://github.com/cfndsl/cfndsl/pull/157) ([johnf](https://github.com/johnf))
956
-
957
981
  **Merged pull requests:**
958
982
 
959
983
  - Add in Route53 Health Check Tags as a type [\#185](https://github.com/cfndsl/cfndsl/pull/185) ([gergnz](https://github.com/gergnz))
data/README.md CHANGED
@@ -6,21 +6,19 @@ cfndsl
6
6
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cfndsl/cfndsl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Join the chat at https://gitter.im/cfndsl/cfndsl](https://badges.gitter.im/cfndsl/cfndsl.svg)](https://gitter.im/cfndsl/cfndsl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
7
 
8
8
  [AWS Cloudformation](http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/GettingStarted.html) templates are an incredibly powerful way to build
9
- sets of resources in Amazon's AWS environment. Unfortunately, because
10
- they are specified in JSON, they are also difficult to write and
11
- maintain:
9
+ sets of resources in Amazon's AWS environment.
10
+ Unfortunately, because they are specified in JSON or YAML, they are also difficult to write and maintain:
12
11
 
13
- * JSON does not allow comments
12
+ * JSON does not allow comments, although CloudFormation now supports YAML
14
13
 
15
- * All structures are JSON, so it is sometimes easy for a person
16
- reading a template to get lost.
14
+ * JSON/YAML templates do not allow re-usable logic
17
15
 
18
- * References and internal functions have a particularly unpleasant syntax.
16
+ * It is easy for a person reading a template to miss the association and dependencies between entries
19
17
 
18
+ * References and internal functions have a particularly unpleasant syntax.
20
19
 
21
- The cnfdsl gem provides a simple DSL that allows you to write equivalent
22
- templates in a more friendly language and generate the correct json
23
- templates by running ruby.
20
+ The cnfdsl gem provides a DSL that allows you to write templates using friendly Ruby logic to generate and validate
21
+ cloudformation templates.
24
22
 
25
23
  ## Getting Started
26
24
 
data/Rakefile CHANGED
@@ -73,6 +73,8 @@ task :bump, :type do |_, args|
73
73
 
74
74
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
75
75
  config.future_release = version
76
+ config.user = 'cfndsl'
77
+ config.project = 'cfndsl'
76
78
  end
77
79
 
78
80
  puts "Bumping gem from version #{CfnDsl::VERSION} to #{version} as a '#{type.capitalize}' release"
@@ -0,0 +1,23 @@
1
+ {
2
+ "broken": "16.2.0",
3
+ "ResourceTypes": {
4
+ "AWS::IoT::ProvisioningTemplate": {
5
+ "patch": {
6
+ "operations": [
7
+ {
8
+ "op": "replace",
9
+ "path": "/Properties/Tags",
10
+ "value": {
11
+ "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-provisioningtemplate.html#cfn-iot-provisioningtemplate-tags",
12
+ "UpdateType": "Mutable",
13
+ "Required": false,
14
+ "Type": "List",
15
+ "ItemType": "Tag"
16
+ }
17
+ }
18
+ ]
19
+ }
20
+ }
21
+ }
22
+ }
23
+
@@ -43,9 +43,10 @@ module CfnDsl
43
43
  params.load_file file
44
44
  when :raw
45
45
  file_parts = file.split('=')
46
- if file_parts[1].downcase == 'true'
46
+ case file_parts[1].downcase
47
+ when 'true'
47
48
  params.set_param(file_parts[0], true)
48
- elsif file_parts[1].downcase == 'false'
49
+ when 'false'
49
50
  params.set_param(file_parts[0], false)
50
51
  else
51
52
  params.set_param(*file.split('='))
@@ -245,7 +245,7 @@ module CfnDsl
245
245
  end
246
246
  end
247
247
 
248
- # rubocop:disable Metrics/PerceivedComplexity
248
+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
249
249
  def _check_refs(container_name, method, source_containers)
250
250
  container = instance_variable_get("@#{container_name}s")
251
251
  return [] unless container
@@ -279,7 +279,7 @@ module CfnDsl
279
279
 
280
280
  invalids
281
281
  end
282
- # rubocop:enable Metrics/PerceivedComplexity
282
+ # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
283
283
 
284
284
  def validate
285
285
  errors = check_refs || []
@@ -10,7 +10,7 @@ module RefCheck
10
10
  end
11
11
 
12
12
  # Build up a set of references.
13
- # rubocop:disable Metrics/PerceivedComplexity
13
+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
14
14
  def build_references(refs = [], origin = nil, method = :all_refs)
15
15
  if respond_to?(method)
16
16
  send(method).each do |ref|
@@ -30,7 +30,7 @@ module RefCheck
30
30
 
31
31
  refs
32
32
  end
33
- # rubocop:enable Metrics/PerceivedComplexity
33
+ # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
34
34
 
35
35
  def ref_children
36
36
  []
@@ -5,7 +5,7 @@ require_relative 'jsonable'
5
5
  module CfnDsl
6
6
  # Handles Resource objects
7
7
  class ResourceDefinition < JSONable
8
- dsl_attr_setter :Type, :DependsOn, :UpdateReplacePolicy, :DeletionPolicy, :Condition, :Metadata
8
+ dsl_attr_setter :Type, :UpdateReplacePolicy, :DeletionPolicy, :Condition, :Metadata
9
9
  dsl_content_object :Property, :UpdatePolicy, :CreationPolicy
10
10
 
11
11
  def add_tag(name, value, propagate = nil)
@@ -16,6 +16,23 @@ module CfnDsl
16
16
  end
17
17
  end
18
18
 
19
+ # DependsOn can be a single value or a list
20
+ def DependsOn(value)
21
+ case @DependsOn
22
+ when nil
23
+ @DependsOn = value
24
+ when Array
25
+ @DependsOn << value
26
+ else
27
+ @DependsOn = [@DependsOn, value]
28
+ end
29
+ if @DependsOn.is_a?(Array)
30
+ @DependsOn.flatten!
31
+ @DependsOn.uniq!
32
+ end
33
+ @DependsOn
34
+ end
35
+
19
36
  def condition_refs
20
37
  [@Condition].flatten.compact.map(&:to_s)
21
38
  end
@@ -7,7 +7,6 @@ require_relative 'globals'
7
7
 
8
8
  module CfnDsl
9
9
  # Runner class to handle commandline invocation
10
- # rubocop:disable Metrics/ClassLength
11
10
  class Runner
12
11
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
13
12
  def self.invoke!
@@ -143,4 +142,3 @@ module CfnDsl
143
142
  end
144
143
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
145
144
  end
146
- # rubocop:enable Metrics/ClassLength
@@ -16,7 +16,7 @@ module CfnDsl
16
16
  { 'Resources' => resources, 'Types' => types, 'Version' => spec.version, 'File' => spec.file }
17
17
  end
18
18
 
19
- # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
19
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/CyclomaticComplexity
20
20
  def self.extract_resources(spec)
21
21
  spec.each_with_object({}) do |(resource_name, resource_info), resources|
22
22
  properties = resource_info['Properties'].each_with_object({}) do |(property_name, property_info), extracted|
@@ -54,7 +54,7 @@ module CfnDsl
54
54
  end
55
55
  # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
56
56
 
57
- # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
57
+ # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
58
58
  def self.extract_types(spec)
59
59
  primitive_types = {
60
60
  'String' => 'String',
@@ -117,9 +117,9 @@ module CfnDsl
117
117
  types
118
118
  end
119
119
  end
120
- # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
120
+ # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
121
121
 
122
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
122
+ # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
123
123
  def self.included(type_def)
124
124
  types_list = extract_from_resource_spec
125
125
  type_def.const_set('Types_Internal', types_list)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CfnDsl
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -215,9 +215,10 @@ module DeepMerge
215
215
  knockout_prefix = options[:knockout_prefix] || false
216
216
  di = options[:debug_indent] || ''
217
217
  if knockout_prefix && overwrite_unmergeable
218
- src_tmp = if source.is_a?(String) # remove knockout string from source before overwriting dest
218
+ src_tmp = case source
219
+ when String # remove knockout string from source before overwriting dest
219
220
  source.gsub(/^#{knockout_prefix}/, '')
220
- elsif source.is_a?(Array) # remove all knockout elements before overwriting dest
221
+ when Array # remove all knockout elements before overwriting dest
221
222
  source.delete_if { |ko_item| ko_item.is_a?(String) && ko_item.match(/^#{knockout_prefix}/) }
222
223
  else
223
224
  source
@@ -188,6 +188,26 @@ describe CfnDsl::CloudFormationTemplate do
188
188
  end
189
189
  end
190
190
 
191
+ it 'composes DependsOn' do
192
+ spec = self
193
+ subject.Resource('SomeResource') do
194
+ d = DependsOn('X')
195
+ spec.expect(d).to spec.eq('X') # start with a single value, stays a single value
196
+ d = DependsOn(%w[Y Z])
197
+ spec.expect(d).to spec.eq(%w[X Y Z]) # concatenates values
198
+ d = DependsOn('Y') # uniqeness
199
+ spec.expect(d).to spec.eq(%w[X Y Z])
200
+ end
201
+ expect(subject.to_json).to eq('{"AWSTemplateFormatVersion":"2010-09-09","Resources":{"SomeResource":{"DependsOn":["X","Y","Z"]}}}')
202
+ end
203
+
204
+ it 'supports single value DependsOn' do
205
+ subject.Resource('SomeResource') do
206
+ DependsOn(:ADependency)
207
+ end
208
+ expect(subject.to_json).to eq('{"AWSTemplateFormatVersion":"2010-09-09","Resources":{"SomeResource":{"DependsOn":"ADependency"}}}')
209
+ end
210
+
191
211
  context 'built-in functions' do
192
212
  it 'FnGetAtt' do
193
213
  func = subject.FnGetAtt('A', 'B')
@@ -64,6 +64,7 @@ describe CfnDsl::CloudFormationTemplate do
64
64
  tr = subject.Resource(:TestResource)
65
65
  tr.Type('Custom-TestType')
66
66
  tr.DependsOn(:TestResource2)
67
+ tr.DependsOn(:TestResource2)
67
68
 
68
69
  t2 = subject.Resource('TestResource2')
69
70
  t2.Type('Custom-TestType')
@@ -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
- if type.is_a?(String)
30
+ case type
31
+ when String
31
32
  expect(types).to have_key(type)
32
- elsif type.is_a?(Hash)
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.1.1
4
+ version: 1.2.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: 2020-06-02 00:00:00.000000000 Z
14
+ date: 2020-07-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json
72
72
  - lib/cfndsl/aws/patches/200_Scrutinies_patch.json
73
73
  - lib/cfndsl/aws/patches/500_BadTagsv13.0.0_patch.json
74
+ - lib/cfndsl/aws/patches/500_BadTagsv16.2.0_patch.json
74
75
  - lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json
75
76
  - lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json
76
77
  - lib/cfndsl/aws/patches/500_NetworkAclEntry_patch.json
@@ -191,8 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  - !ruby/object:Gem::Version
192
193
  version: '0'
193
194
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.7.7
195
+ rubygems_version: 3.0.8
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: AWS Cloudformation DSL