aws-cfn-compiler 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/aws-cfn-compiler.iml +3 -0
- data/lib/aws/cfn/compiler/version.rb +1 -1
- data/lib/aws/cfn/compiler.rb +55 -18
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NDFhNGY3ZDE0MTU0NzBjMDgyZTk4ZDIxYTYyODZiZGE5NGRkYjc4OQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92b9e67123205941b72a91a16c5c42998c4cb449
|
4
|
+
data.tar.gz: f14ce4e2eccfce862cc596547a5d01ec99a94f9f
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjQ2YTFhYjdjNmRiYzc2MTkyMmU3ZDQxNDYwY2EyMzM1ODg1NmMyZWNkNWM4
|
11
|
-
NTU3YWE1MzI2MzVkNTU1MWFlMjg3ZDA1NTM4ZGVlY2M4NmNlYTU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2Y5NzhhOTBiOGJiMGY5ODRmZTRkOTVmM2EwMDgyNGY1M2ExYzEzNzRjNDEz
|
14
|
-
MTVkMDI3ZDcwMTk1YzhmYjBmNzEwMDA1MWVjOGM4Njg2OGRkYWFhMTNjOWMz
|
15
|
-
YzdiNjc3NTY4NjUyZjRmNDZlMDJjYWJjMzA1YzhjMDZlYjgyMWU=
|
6
|
+
metadata.gz: 69ef6ab2cb372b9f77377cda9746f8f6adfbb3595d225d044497d90ba9f317b772a84af100cb6132c9fc66a3da38e87b61cd8e04f39421005b3f5fdbf2ddbf55
|
7
|
+
data.tar.gz: 785e9f58bf67b9125096e606d0420d0024b4197730eb4f54f6449e784bf03b733ed65738c6139498c7c3e7207e1ca7fea003abe2f8c31c04fdaca79227d81005
|
data/aws-cfn-compiler.iml
CHANGED
@@ -18,7 +18,10 @@
|
|
18
18
|
<orderEntry type="jdk" jdkName="RVM: ruby-1.9.3-p547 [aws-cfn-compile]" jdkType="RUBY_SDK" />
|
19
19
|
<orderEntry type="sourceFolder" forTests="false" />
|
20
20
|
<orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.2.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="aws-cfn-dsl (v0.0.4, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
21
22
|
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="cloudformation-ruby-dsl (v0.4.3, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="detabulator (v0.1.0, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
22
25
|
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
23
26
|
<orderEntry type="library" scope="PROVIDED" name="psych (v2.0.5, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
24
27
|
<orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, RVM: ruby-1.9.3-p547 [aws-cfn-compile]) [gem]" level="application" />
|
data/lib/aws/cfn/compiler.rb
CHANGED
@@ -68,20 +68,12 @@ module Aws
|
|
68
68
|
|
69
69
|
def validate(compiled)
|
70
70
|
raise 'No Resources!?' unless compiled['Resources']
|
71
|
-
#raise 'No Parameters!?' unless compiled['Parameters']
|
72
|
-
names = compiled['Resources'].keys + (compiled['Parameters'].nil? ? [] : compiled['Parameters'].keys)
|
73
|
-
refs = find_refs(compiled).select { |a| !(a =~ /^AWS::/) }
|
74
71
|
|
75
|
-
|
76
|
-
puts '!!! Unknown references !!!'
|
77
|
-
(refs-names).each do |name|
|
78
|
-
puts " #{name}"
|
79
|
-
end
|
80
|
-
abort!
|
81
|
-
end
|
82
|
-
puts ' References validated'
|
83
|
-
names = compiled['Resources'].keys + (compiled['Mappings'].nil? ? [] : compiled['Mappings'].keys)
|
72
|
+
# Mappings => Resources
|
84
73
|
maps = find_maps(compiled) #.select { |a| !(a =~ /^AWS::/) }
|
74
|
+
rscs = compiled['Resources'].keys
|
75
|
+
mpgs = compiled['Mappings'].nil? ? [] : compiled['Mappings'].keys
|
76
|
+
names = rscs+mpgs
|
85
77
|
|
86
78
|
unless (maps-names).empty?
|
87
79
|
puts '!!! Unknown mappings !!!'
|
@@ -90,6 +82,21 @@ module Aws
|
|
90
82
|
end
|
91
83
|
abort!
|
92
84
|
end
|
85
|
+
puts ' Mappings validated'
|
86
|
+
|
87
|
+
# Parameters => Resources => Outputs
|
88
|
+
refs = find_refs(compiled).select { |a,_| !(a =~ /^AWS::/) }
|
89
|
+
prms = compiled['Parameters'].keys rescue []
|
90
|
+
# outs = compiled['Outputs'].keys rescue []
|
91
|
+
names = rscs+prms
|
92
|
+
|
93
|
+
unless (refs.keys-names).empty?
|
94
|
+
puts '!!! Unknown references !!!'
|
95
|
+
(refs.keys-names).each do |name|
|
96
|
+
puts " #{name} from #{refs[name][0]}:#{refs[name][1]}"
|
97
|
+
end
|
98
|
+
abort!
|
99
|
+
end
|
93
100
|
puts ' References validated'
|
94
101
|
end
|
95
102
|
|
@@ -155,21 +162,51 @@ module Aws
|
|
155
162
|
exit
|
156
163
|
end
|
157
164
|
|
158
|
-
def find_refs(hash)
|
165
|
+
def find_refs(hash, type='Reference', parent='')
|
166
|
+
h = {}
|
167
|
+
newparent = parent
|
159
168
|
if hash.is_a? Hash
|
160
|
-
tr = []
|
161
169
|
hash.keys.collect do |key|
|
170
|
+
if %w{Mappings Parameters Resources Outputs}.include? key
|
171
|
+
type = key#.gsub(/s$/, '')
|
172
|
+
newparent = key
|
173
|
+
elsif %w{Mappings Parameters Resources Outputs}.include? parent
|
174
|
+
newparent = key
|
175
|
+
end
|
162
176
|
if %w{Ref SourceSecurityGroupName CacheSecurityGroupNames SecurityGroupNames}.include? key
|
163
|
-
hash[key]
|
177
|
+
h = { hash[key] => [type,newparent] }
|
164
178
|
elsif 'Fn::GetAtt' == key
|
165
|
-
hash[key].first
|
179
|
+
h = { hash[key].first => [type,newparent] }
|
166
180
|
else
|
167
|
-
find_refs(hash[key])
|
181
|
+
a = find_refs(hash[key],type,newparent)
|
182
|
+
h = merge(h, a, *[type,newparent])
|
168
183
|
end
|
169
184
|
end.flatten.compact.uniq
|
170
185
|
elsif hash.is_a? Array
|
171
|
-
hash.
|
186
|
+
a = hash.map{|i| find_refs(i,type,newparent) }
|
187
|
+
h = merge(h, a, type, *[type,newparent])
|
188
|
+
end
|
189
|
+
h
|
190
|
+
end
|
191
|
+
|
192
|
+
def merge(h, a, *type)
|
193
|
+
if a.is_a? Hash
|
194
|
+
if a.size > 0
|
195
|
+
h.merge! a
|
196
|
+
end
|
197
|
+
else
|
198
|
+
a.flatten.compact.uniq.map { |i|
|
199
|
+
if i.is_a? Hash
|
200
|
+
if i.size > 0
|
201
|
+
h.merge! i
|
202
|
+
h
|
203
|
+
end
|
204
|
+
else
|
205
|
+
h[i] = type
|
206
|
+
end
|
207
|
+
}
|
172
208
|
end
|
209
|
+
h
|
173
210
|
end
|
174
211
|
|
175
212
|
def find_maps(hash)
|
metadata
CHANGED
@@ -1,117 +1,117 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-cfn-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PKinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: psych
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: aws-cfn-dsl
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.0.1
|
62
|
-
- - ~>
|
62
|
+
- - "~>"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0.0'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 0.0.1
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: slop
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: bundler
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - ~>
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '1.6'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - ~>
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.6'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rake
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
description: The idea is to create a folder structure to better manage pieces of a
|
@@ -124,9 +124,9 @@ executables:
|
|
124
124
|
extensions: []
|
125
125
|
extra_rdoc_files: []
|
126
126
|
files:
|
127
|
-
- .gitignore
|
128
|
-
- .ruby-gemset
|
129
|
-
- .ruby-version
|
127
|
+
- ".gitignore"
|
128
|
+
- ".ruby-gemset"
|
129
|
+
- ".ruby-version"
|
130
130
|
- Gemfile
|
131
131
|
- LICENSE.txt
|
132
132
|
- README.md
|
@@ -160,12 +160,12 @@ require_paths:
|
|
160
160
|
- lib
|
161
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- -
|
163
|
+
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|