convection 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -2
- data/bin/convection +6 -13
- data/lib/convection/dsl/helpers.rb +2 -0
- data/lib/convection/dsl/intrinsic_functions.rb +12 -0
- data/lib/convection/dsl/terraform_intrinsic_functions.rb +35 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc9a19505a82416b030b023c4a0c26b1fed5ba7
|
4
|
+
data.tar.gz: 52199f6b587c4407aa1343933044cb58e5c1aac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f432b877726684a99488e7774312f7c038e34248d40d315fb163ecbada1924766c934318d1da23c115432c02f0bb2c8e96ee1784db31768381ee739c657f0f
|
7
|
+
data.tar.gz: 40ab46a04114fe749a3ac5dc026b69512e9ab8e215b812356a81860323256be9d19ceeae7ec6d47afa46149a0e4622ee0f52205a9016c10bfac0bf7b5275bfcc
|
data/.rubocop.yml
CHANGED
@@ -24,14 +24,16 @@ Performance/RedundantBlockCall:
|
|
24
24
|
Style/SignalException:
|
25
25
|
Enabled: false
|
26
26
|
|
27
|
+
Metrics/LineLength:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/convection/dsl/terraform_intrinsic_functions.rb'
|
30
|
+
|
27
31
|
# AbcSize:
|
28
32
|
# Max: 24
|
29
33
|
# ClassLength:
|
30
34
|
# Max: 256
|
31
35
|
# CyclomaticComplexity:
|
32
36
|
# Max: 12
|
33
|
-
# LineLength:
|
34
|
-
# Max: 120
|
35
37
|
# MethodLength:
|
36
38
|
# Max: 32
|
37
39
|
# PerceivedComplexity:
|
data/bin/convection
CHANGED
@@ -140,13 +140,13 @@ module Convection
|
|
140
140
|
|
141
141
|
init_cloud
|
142
142
|
template = @cloud.stacks.fetch(stack_name).template
|
143
|
-
|
143
|
+
|
144
|
+
# Beware of 🐲. This patches this instance to include terraform compatible intrinsic functions where possible.
|
144
145
|
#
|
145
146
|
# This should only be done in single threaded environment in the terraform-export command as it breaks usage of cloudformation psuedo-functions.
|
146
|
-
#
|
147
|
-
# e.g. #get_att("Bucket", "Arn") returns "aws_s3_bucket.bucket.arn" instead of { "Fn::GetAtt" => ["Bucket", "Arn"] }.
|
148
147
|
require 'convection/dsl/terraform_intrinsic_functions'
|
149
|
-
|
148
|
+
Convection::DSL::TerraformIntrinsicFunctions.overload(Convection::DSL::IntrinsicFunctions.mixers)
|
149
|
+
|
150
150
|
template.resource_collections.each(&method(:import_resources))
|
151
151
|
template.resources.each(&method(:import_resources))
|
152
152
|
end
|
@@ -158,14 +158,9 @@ module Convection
|
|
158
158
|
|
159
159
|
private
|
160
160
|
|
161
|
-
# rubocop:disable Style/AsciiComments
|
162
|
-
|
163
161
|
def import_resources(_resource_name, resource)
|
164
|
-
#
|
165
|
-
|
166
|
-
# This should only be done in single threaded environment in the terraform-export command as it breaks usage of cloudformation psuedo-functions.
|
167
|
-
require 'convection/dsl/terraform_intrinsic_functions'
|
168
|
-
resource.extend(Convection::DSL::TerraformIntrinsicFunctions)
|
162
|
+
# Reload this resource to ensure configuration is up to date. Amazon psuedo functions will have changed their return values.
|
163
|
+
resource.execute
|
169
164
|
|
170
165
|
if resource.respond_to?(:to_hcl_json)
|
171
166
|
empty_directory options[:output_directory]
|
@@ -192,8 +187,6 @@ module Convection
|
|
192
187
|
puts # Print an additional new line
|
193
188
|
end
|
194
189
|
|
195
|
-
# rubocop:enable Style/AsciiComments
|
196
|
-
|
197
190
|
def operation(task_name, stack)
|
198
191
|
work_q = Queue.new
|
199
192
|
semaphore = Mutex.new
|
@@ -1,8 +1,20 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Convection
|
2
4
|
module DSL
|
3
5
|
##
|
4
6
|
# Formatting helpers for Intrinsic Functions
|
5
7
|
module IntrinsicFunctions
|
8
|
+
def self.included(base)
|
9
|
+
mixers << base
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.mixers
|
15
|
+
@mixers ||= Set.new
|
16
|
+
end
|
17
|
+
|
6
18
|
def base64(content)
|
7
19
|
{
|
8
20
|
'Fn::Base64' => content
|
@@ -1,81 +1,101 @@
|
|
1
|
-
require 'active_support/core_ext/string/inflections'
|
2
|
-
|
3
1
|
module Convection
|
4
2
|
module DSL
|
3
|
+
# AWS psuedo-functions overridden to be terraform compatible, sort of!
|
5
4
|
module TerraformIntrinsicFunctions
|
5
|
+
# Lazily require inflections so loaded when invoking terraform-export.
|
6
|
+
require 'active_support/core_ext/string/inflections'
|
7
|
+
|
8
|
+
def self.extended(base)
|
9
|
+
return base.include(self) if base.is_a?(Class) || base.is_a?(Module)
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.overload(objects)
|
15
|
+
mod = self
|
16
|
+
objects.each { |o| o.extend(mod) }
|
17
|
+
end
|
18
|
+
|
6
19
|
def base64(_content)
|
7
20
|
%q(base64(#{content.to_json}))
|
8
21
|
end
|
9
22
|
|
10
23
|
def fn_and(*)
|
11
|
-
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{
|
24
|
+
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{terraform_name})"
|
12
25
|
'${todo.fn_and.ATTRIBUTE.set_in_count}'
|
13
26
|
end
|
14
27
|
|
15
28
|
def fn_equals(*)
|
16
|
-
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{
|
29
|
+
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{terraform_name})"
|
17
30
|
'${todo.fn_equals.ATTRIBUTE.set_in_count}'
|
18
31
|
end
|
19
32
|
|
20
33
|
def fn_if(*)
|
21
|
-
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{
|
34
|
+
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{terraform_name})"
|
22
35
|
'${todo.fn_if.ATTRIBUTE.set_in_count}'
|
23
36
|
end
|
24
37
|
|
25
38
|
def fn_import_value(*)
|
26
|
-
warn "WARNING: Fn::ImportValue cannot be inferred when migrated to terraform. Please pull in this input through a variable or local value in your configuration. #{self.class}(#{
|
39
|
+
warn "WARNING: Fn::ImportValue cannot be inferred when migrated to terraform. Please pull in this input through a variable or local value in your configuration. #{self.class}(#{terraform_name})"
|
27
40
|
'${todo.fn_import_value.ATTRIBUTE}'
|
28
41
|
end
|
29
42
|
|
30
43
|
def fn_not(*)
|
31
|
-
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{
|
44
|
+
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{terraform_name})"
|
32
45
|
'${todo.fn_not.ATTRIBUTE.set_in_count}'
|
33
46
|
end
|
34
47
|
|
35
48
|
def fn_or(*)
|
36
|
-
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{
|
49
|
+
warn "WARNING: Condition functions cannot be inferred when migrating to terraform. Please set count on migrated resources manually. #{self.class}(#{terraform_name})"
|
37
50
|
'${todo.fn_or.ATTRIBUTE.set_in_count}'
|
38
51
|
end
|
39
52
|
|
40
53
|
def fn_sub(*)
|
41
|
-
warn "WARNING: Fn::Sub cannot be inferred when migrating to terraform. Please use ${replace(str, search, replace)} instead. #{self.class}(#{
|
54
|
+
warn "WARNING: Fn::Sub cannot be inferred when migrating to terraform. Please use ${replace(str, search, replace)} instead. #{self.class}(#{terraform_name})"
|
42
55
|
'${replace(todo.fn_sub.STRING, todo.fn_sub.SEARCH, todo.fn_sub.REPLACE)}'
|
43
56
|
end
|
44
57
|
|
45
58
|
def find_in_map(*)
|
46
|
-
warn "WARNING: Fn::FindInMap cannot be inferred when migrating to terraform. Please consult with the interpolation syntax terraform docs #{self.class}(#{
|
59
|
+
warn "WARNING: Fn::FindInMap cannot be inferred when migrating to terraform. Please consult with the interpolation syntax terraform docs #{self.class}(#{terraform_name})"
|
47
60
|
'${lookup(lookup(YOUR_MAP, YOUR_TOP_LEVEL_KEY), YOUR_NESTED_KEY)}'
|
48
61
|
end
|
49
62
|
|
50
63
|
def get_att(resource_name, attr_name)
|
51
64
|
interpolation_string = "${#{terraform_resource_type(resource_name)}.#{terraform_resource_name(resource_name)}.#{attr_name.underscore}}"
|
52
|
-
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::GetAtt. Please consult with the interpolation syntax terraform docs and docs for this resource type in terraform to verify compatablity. #{self.class}(#{
|
65
|
+
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::GetAtt. Please consult with the interpolation syntax terraform docs and docs for this resource type in terraform to verify compatablity. #{self.class}(#{terraform_name})"
|
53
66
|
interpolation_string
|
54
67
|
end
|
55
68
|
|
56
69
|
def get_azs(*)
|
57
|
-
warn "WARNING: Inferring you want to use ${var.availability_zones} instead of Fn::GetAZs. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{
|
70
|
+
warn "WARNING: Inferring you want to use ${var.availability_zones} instead of Fn::GetAZs. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{terraform_name})"
|
58
71
|
'${var.availability_zones}'
|
59
72
|
end
|
60
73
|
|
61
74
|
def join(delimiter, *values)
|
62
75
|
interpolation_string = "${join(\"#{delimiter}\", list(#{values.map { |o| "\"#{o}\"" }.join(', ')}))"
|
63
|
-
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Join. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{
|
76
|
+
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Join. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{terraform_name})"
|
64
77
|
interpolation_string
|
65
78
|
end
|
66
79
|
|
67
80
|
def select(index, *objects)
|
68
81
|
interpolation_string = "${element(list(#{objects.map { |o| "\"#{o}\"" }.join(', ')}), #{index})"
|
69
|
-
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Select. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{
|
82
|
+
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Select. Please consult with the interpolation syntax terraform docs to verify compatablity. Additionally you should attempt to use variables in place of a literal list. #{self.class}(#{terraform_name})"
|
70
83
|
interpolation_string
|
71
84
|
end
|
72
85
|
|
73
86
|
def fn_ref(resource_name)
|
74
87
|
interpolation_string = "${#{terraform_resource_type(resource_name)}.#{terraform_resource_name(resource_name)}.id}"
|
75
|
-
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Ref. Please consult with the interpolation syntax terraform docs and docs for this resource type in terraform to verify compatablity. #{self.class}(#{
|
88
|
+
warn "WARNING: Inferring you want to use #{interpolation_string} in place of Fn::Ref. Please consult with the interpolation syntax terraform docs and docs for this resource type in terraform to verify compatablity. #{self.class}(#{terraform_name})"
|
76
89
|
interpolation_string
|
77
90
|
end
|
78
91
|
|
92
|
+
def terraform_name
|
93
|
+
return name if respond_to?(:name)
|
94
|
+
return sid if respond_to?(:sid)
|
95
|
+
|
96
|
+
object_id
|
97
|
+
end
|
98
|
+
|
79
99
|
def terraform_resource_name(resource_name)
|
80
100
|
resource_name.underscore
|
81
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|