tfw 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bc1a297f3a4298321ef182f415a28d25855a65fb9c221c54733b91baa1087e3
4
- data.tar.gz: 2062ad35f45c0939844fabf28cc2b67e7c8e189911b5a73b3885aa7df36aab9f
3
+ metadata.gz: 7b0c2b01dc0ddb7fb04866d224078305f07d8e8799c316744dd4a5df4f592ded
4
+ data.tar.gz: b7b0ae7609fafb733ccd124b6dcf7b47d6aa186837432ace94b13dd4a96befde
5
5
  SHA512:
6
- metadata.gz: 8521b1c5ae3ca1c671ae43744033a162427abde06084aa7e6f117196c821ea0b425d9e963f7a7333997a19ca53d601804b768348baac3612074a07fcd34f2a94
7
- data.tar.gz: 18f7ac5a1b377bb88396577503447fb906232da4376e34ee77eb8072f8c926a4fa906a29f28fd29bf268a7ab27ae08c27548d4845acf7152273267dd762fe1d0
6
+ metadata.gz: 2afd6ef9fe9192169571a9c7b055d5ee051e94b65ee7e97a1f31441ae238881c64025b25e0c7007a632307c70f7bf8764c72f04b5f4db910d5a63d3eac9532b1
7
+ data.tar.gz: 45d8bfbc8e1ecc952a2b683ab51c377d9ce5c91c1a987d0137562e8026b39c615c0e2ad67d2d9a3dfb8415b0414b561a29b1dc56d8874bbbf313ad58bb2be759
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tfw (0.1.14)
4
+ tfw (0.1.15)
5
5
  tfdsl (= 0.1.10)
6
6
 
7
7
  GEM
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.14'
4
+ VERSION = '0.1.15'
5
5
  end
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.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Lopo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-07 00:00:00.000000000 Z
11
+ date: 2020-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tfdsl
@@ -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