tfw 0.1.11 → 0.1.16

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: 0db3357d383025ad106278eba178bf1055488261573a5a0428f4e99718d39e0e
4
- data.tar.gz: 8d9c8bae4f4e2ac13d9f75c056c4ff8ae146eeb112b572457fb441f68c886155
3
+ metadata.gz: 810ea20c2c8e59f8b72f15731770a8114529f82c8e47ae6af90155dfc90718bb
4
+ data.tar.gz: 755bf3f821643fecbf02804af9306365683114bf486b092f4de44f11eca3006d
5
5
  SHA512:
6
- metadata.gz: 82eea2e76375be89fd1f740090c54ea48699ee208b2d9b4050d1c4dadf8487a4afc372efa8f45c9a6ee459318a71d21ea23e269eac593aaae57b05b6b1e0827d
7
- data.tar.gz: cfb2dbc06fcf90e9e42c9e390f398292d8e33a3eda1ea57bed271404a652dd8c67689b9fdc52a7aaf488f016e9e41cf116837cdb3f99aeacda6434664ff8926b
6
+ metadata.gz: d2d7003ab15174b658e8e4075a6a054ca0d00dc455ab3e69051b6173673627e7743d0cc18d925ea7f8a79f38f9fa886f29383052ae7b1445ef7f396224d7cb07
7
+ data.tar.gz: 2040765f80f3126b135a6b9e8c9e547e5e4ae5abce2c1e2f96677a682dd5cec3e19eed15666a8055fcc280e6e176db3decc58c73db326b8ce44d61f5f516b347
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tfw (0.1.10)
5
- tfdsl (= 0.1.7)
4
+ tfw (0.1.16)
5
+ tfdsl (= 0.1.11)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -15,9 +15,10 @@ GEM
15
15
  term-ansicolor (~> 1.3)
16
16
  thor (~> 0.19.4)
17
17
  tins (~> 1.6)
18
+ deep_merge (1.2.1)
18
19
  docile (1.3.1)
19
20
  jaro_winkler (1.5.4)
20
- json (2.1.0)
21
+ json (2.3.1)
21
22
  method_source (0.9.2)
22
23
  minitest (5.12.2)
23
24
  parallel (1.19.1)
@@ -43,7 +44,8 @@ GEM
43
44
  simplecov-html (0.10.2)
44
45
  term-ansicolor (1.7.1)
45
46
  tins (~> 1.0)
46
- tfdsl (0.1.7)
47
+ tfdsl (0.1.11)
48
+ deep_merge (~> 1.2)
47
49
  thor (0.19.4)
48
50
  tins (1.20.2)
49
51
  unicode-display_width (1.6.1)
data/lib/tfw.rb CHANGED
@@ -14,6 +14,7 @@ module TFW
14
14
 
15
15
  require "#{LIB_DIR}/setters"
16
16
  require "#{LIB_DIR}/module"
17
+ require "#{LIB_DIR}/aws_sg_workaround"
17
18
 
18
19
  WORKSPACE = './.tfw'
19
20
  FileUtils.mkdir_p WORKSPACE
@@ -92,7 +93,7 @@ module TFW
92
93
 
93
94
  if as_json?
94
95
  stack_file = "#{stack_file}.json"
95
- File.write stack_file, pretty_json(stack.to_json)
96
+ File.write stack_file, pretty_json(AwsSgWorkaround.fix(stack.to_json))
96
97
  else
97
98
  File.write stack_file, stack
98
99
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TFW
4
+ # This module is a workaround the issue that when using json some fields that are optional become required
5
+ # https://github.com/hashicorp/terraform/issues/23347
6
+ module AwsSgWorkaround
7
+ module_function
8
+
9
+ def fix(stack_json)
10
+ stack = JSON.parse stack_json
11
+ return stack.to_json unless stack.key? 'resource'
12
+
13
+ r = stack['resource']
14
+ return stack.to_json unless r.key? 'aws_security_group'
15
+
16
+ asg = r['aws_security_group']
17
+ asg.each do |_, sg|
18
+ replace_and_fill sg, 'egress' if sg.key? 'egress'
19
+ replace_and_fill sg, 'ingress' if sg.key? 'ingress'
20
+ end
21
+ stack.to_json
22
+ end
23
+
24
+ def replace_and_fill(obj, key)
25
+ backup = obj[key]
26
+ fill_fields(backup)
27
+ obj[key] = [backup]
28
+ end
29
+
30
+ def fill_fields(obj)
31
+ obj['description'] = '' unless obj.key? 'description'
32
+ obj['security_groups'] = [] unless obj.key? 'security_groups'
33
+ obj['self'] = false unless obj.key? 'self'
34
+ obj['ipv6_cidr_blocks'] = [] unless obj.key? 'ipv6_cidr_blocks'
35
+ obj['prefix_list_ids'] = [] unless obj.key? 'prefix_list_ids'
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TFW
4
- VERSION = '0.1.11'
4
+ VERSION = '0.1.16'
5
5
  end
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ['lib']
37
37
 
38
- spec.add_dependency 'tfdsl', '0.1.7'
38
+ spec.add_dependency 'tfdsl', '0.1.11'
39
39
 
40
40
  spec.add_development_dependency 'bundler', '~> 1.17'
41
41
  spec.add_development_dependency 'coveralls', '~> 0.8'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Lopo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tfdsl
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.7
19
+ version: 0.1.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.7
26
+ version: 0.1.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +132,7 @@ files:
132
132
  - exe/tfw
133
133
  - exe/tfw-test
134
134
  - lib/tfw.rb
135
+ - lib/tfw/aws_sg_workaround.rb
135
136
  - lib/tfw/module.rb
136
137
  - lib/tfw/setters.rb
137
138
  - lib/tfw/state.rb
@@ -142,7 +143,7 @@ licenses:
142
143
  - MIT
143
144
  metadata:
144
145
  homepage_uri: https://github.com/tlopo-ruby/tfw
145
- post_install_message:
146
+ post_install_message:
146
147
  rdoc_options: []
147
148
  require_paths:
148
149
  - lib
@@ -157,8 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
160
- rubygems_version: 3.0.3
161
- signing_key:
161
+ rubygems_version: 3.1.2
162
+ signing_key:
162
163
  specification_version: 4
163
164
  summary: Terraform Wrapper using Terraform DSL for Ruby
164
165
  test_files: []