cfndsl 0.4.4 → 0.5.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rubocop.yml +23 -0
- data/Gemfile +4 -0
- data/Rakefile +19 -17
- data/bin/cfndsl +20 -20
- data/cfndsl.gemspec +16 -15
- data/lib/cfndsl.rb +62 -68
- data/lib/cfndsl/aws/cloud_formation_template.rb +16 -0
- data/lib/cfndsl/aws/types.rb +12 -0
- data/lib/cfndsl/{aws_types.yaml → aws/types.yaml} +0 -0
- data/lib/cfndsl/{Conditions.rb → conditions.rb} +5 -7
- data/lib/cfndsl/creation_policy.rb +21 -0
- data/lib/cfndsl/errors.rb +29 -0
- data/lib/cfndsl/generate_types.rb +154 -0
- data/lib/cfndsl/jsonable.rb +214 -0
- data/lib/cfndsl/mappings.rb +23 -0
- data/lib/cfndsl/metadata.rb +16 -0
- data/lib/cfndsl/module.rb +52 -51
- data/lib/cfndsl/names.rb +5 -5
- data/lib/cfndsl/orchestration_template.rb +173 -0
- data/lib/cfndsl/os/heat_template.rb +16 -0
- data/lib/cfndsl/os/types.rb +12 -0
- data/lib/cfndsl/{os_types.yaml → os/types.yaml} +11 -11
- data/lib/cfndsl/{Outputs.rb → outputs.rb} +3 -4
- data/lib/cfndsl/{Parameters.rb → parameters.rb} +12 -13
- data/lib/cfndsl/plurals.rb +34 -0
- data/lib/cfndsl/properties.rb +21 -0
- data/lib/cfndsl/rake_task.rb +9 -7
- data/lib/cfndsl/ref_check.rb +44 -0
- data/lib/cfndsl/{Resources.rb → resources.rb} +13 -15
- data/lib/cfndsl/types.rb +151 -0
- data/lib/cfndsl/update_policy.rb +25 -0
- data/lib/cfndsl/version.rb +1 -1
- data/sample/autoscale.rb +152 -158
- data/sample/autoscale2.rb +151 -155
- data/sample/circular.rb +30 -33
- data/sample/codedeploy.rb +35 -36
- data/sample/config_service.rb +120 -0
- data/sample/ecs.rb +39 -39
- data/sample/iam_policies.rb +82 -0
- data/sample/lambda.rb +20 -24
- data/sample/s3.rb +11 -11
- data/sample/t1.rb +7 -9
- data/sample/vpc_example.rb +50 -0
- data/sample/vpc_with_vpn_example.rb +97 -0
- data/spec/cfndsl_spec.rb +22 -11
- data/spec/fixtures/heattest.rb +13 -14
- data/spec/fixtures/test.rb +56 -53
- metadata +36 -30
- data/lib/cfndsl/CloudFormationTemplate.rb +0 -267
- data/lib/cfndsl/CreationPolicy.rb +0 -25
- data/lib/cfndsl/Errors.rb +0 -31
- data/lib/cfndsl/JSONable.rb +0 -235
- data/lib/cfndsl/Mappings.rb +0 -25
- data/lib/cfndsl/Metadata.rb +0 -22
- data/lib/cfndsl/Plurals.rb +0 -35
- data/lib/cfndsl/Properties.rb +0 -25
- data/lib/cfndsl/RefCheck.rb +0 -48
- data/lib/cfndsl/Types.rb +0 -309
- data/lib/cfndsl/UpdatePolicy.rb +0 -29
- data/sample/config-service.rb +0 -119
- data/sample/iam-policies.rb +0 -82
- data/sample/vpc-example.rb +0 -51
- data/sample/vpc-with-vpn-example.rb +0 -97
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: 0.
|
4
|
+
version: 0.5.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
description: DSL for creating AWS Cloudformation templates
|
@@ -34,8 +34,9 @@ executables:
|
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
|
-
- .gitignore
|
38
|
-
- .
|
37
|
+
- ".gitignore"
|
38
|
+
- ".rubocop.yml"
|
39
|
+
- ".travis.yml"
|
39
40
|
- Gemfile
|
40
41
|
- LICENSE
|
41
42
|
- README.md
|
@@ -43,41 +44,46 @@ files:
|
|
43
44
|
- bin/cfndsl
|
44
45
|
- cfndsl.gemspec
|
45
46
|
- lib/cfndsl.rb
|
46
|
-
- lib/cfndsl/
|
47
|
-
- lib/cfndsl/
|
48
|
-
- lib/cfndsl/
|
49
|
-
- lib/cfndsl/
|
50
|
-
- lib/cfndsl/
|
51
|
-
- lib/cfndsl/
|
52
|
-
- lib/cfndsl/
|
53
|
-
- lib/cfndsl/
|
54
|
-
- lib/cfndsl/
|
55
|
-
- lib/cfndsl/
|
56
|
-
- lib/cfndsl/Properties.rb
|
57
|
-
- lib/cfndsl/RefCheck.rb
|
58
|
-
- lib/cfndsl/Resources.rb
|
59
|
-
- lib/cfndsl/Types.rb
|
60
|
-
- lib/cfndsl/UpdatePolicy.rb
|
61
|
-
- lib/cfndsl/aws_types.yaml
|
47
|
+
- lib/cfndsl/aws/cloud_formation_template.rb
|
48
|
+
- lib/cfndsl/aws/types.rb
|
49
|
+
- lib/cfndsl/aws/types.yaml
|
50
|
+
- lib/cfndsl/conditions.rb
|
51
|
+
- lib/cfndsl/creation_policy.rb
|
52
|
+
- lib/cfndsl/errors.rb
|
53
|
+
- lib/cfndsl/generate_types.rb
|
54
|
+
- lib/cfndsl/jsonable.rb
|
55
|
+
- lib/cfndsl/mappings.rb
|
56
|
+
- lib/cfndsl/metadata.rb
|
62
57
|
- lib/cfndsl/module.rb
|
63
58
|
- lib/cfndsl/names.rb
|
64
|
-
- lib/cfndsl/
|
59
|
+
- lib/cfndsl/orchestration_template.rb
|
60
|
+
- lib/cfndsl/os/heat_template.rb
|
61
|
+
- lib/cfndsl/os/types.rb
|
62
|
+
- lib/cfndsl/os/types.yaml
|
63
|
+
- lib/cfndsl/outputs.rb
|
64
|
+
- lib/cfndsl/parameters.rb
|
65
|
+
- lib/cfndsl/plurals.rb
|
66
|
+
- lib/cfndsl/properties.rb
|
65
67
|
- lib/cfndsl/rake_task.rb
|
68
|
+
- lib/cfndsl/ref_check.rb
|
69
|
+
- lib/cfndsl/resources.rb
|
70
|
+
- lib/cfndsl/types.rb
|
71
|
+
- lib/cfndsl/update_policy.rb
|
66
72
|
- lib/cfndsl/version.rb
|
67
73
|
- sample/autoscale.rb
|
68
74
|
- sample/autoscale.template
|
69
75
|
- sample/autoscale2.rb
|
70
76
|
- sample/circular.rb
|
71
77
|
- sample/codedeploy.rb
|
72
|
-
- sample/
|
78
|
+
- sample/config_service.rb
|
73
79
|
- sample/ecs.rb
|
74
|
-
- sample/
|
80
|
+
- sample/iam_policies.rb
|
75
81
|
- sample/lambda.rb
|
76
82
|
- sample/s3.rb
|
77
83
|
- sample/t1.rb
|
78
84
|
- sample/t1.yaml
|
79
|
-
- sample/
|
80
|
-
- sample/
|
85
|
+
- sample/vpc_example.rb
|
86
|
+
- sample/vpc_with_vpn_example.rb
|
81
87
|
- spec/cfndsl_spec.rb
|
82
88
|
- spec/fixtures/heattest.rb
|
83
89
|
- spec/fixtures/test.rb
|
@@ -92,17 +98,17 @@ require_paths:
|
|
92
98
|
- lib
|
93
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
100
|
requirements:
|
95
|
-
- -
|
101
|
+
- - ">="
|
96
102
|
- !ruby/object:Gem::Version
|
97
103
|
version: '0'
|
98
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
105
|
requirements:
|
100
|
-
- -
|
106
|
+
- - ">"
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
108
|
+
version: 1.3.1
|
103
109
|
requirements: []
|
104
110
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.4.
|
111
|
+
rubygems_version: 2.4.8
|
106
112
|
signing_key:
|
107
113
|
specification_version: 4
|
108
114
|
summary: AWS Cloudformation DSL
|
@@ -1,267 +0,0 @@
|
|
1
|
-
require 'cfndsl/JSONable'
|
2
|
-
require 'cfndsl/names'
|
3
|
-
|
4
|
-
module CfnDsl
|
5
|
-
class OrchestrationTemplate < JSONable
|
6
|
-
##
|
7
|
-
# Handles the overall template object
|
8
|
-
dsl_attr_setter :AWSTemplateFormatVersion, :Description
|
9
|
-
dsl_content_object :Condition, :Parameter, :Output, :Resource, :Mapping
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@AWSTemplateFormatVersion = "2010-09-09"
|
13
|
-
end
|
14
|
-
|
15
|
-
@@globalRefs = {
|
16
|
-
"AWS::NotificationARNs" => 1,
|
17
|
-
"AWS::Region" => 1,
|
18
|
-
"AWS::StackId" => 1,
|
19
|
-
"AWS::StackName" => 1,
|
20
|
-
"AWS::AccountId" => 1,
|
21
|
-
"AWS::NoValue" => 1
|
22
|
-
}
|
23
|
-
|
24
|
-
def isValidRef( ref, origin=nil)
|
25
|
-
ref = ref.to_s
|
26
|
-
origin = origin.to_s if origin
|
27
|
-
|
28
|
-
return true if @@globalRefs.has_key?( ref )
|
29
|
-
|
30
|
-
return true if @Parameters && @Parameters.has_key?( ref )
|
31
|
-
|
32
|
-
if( @Resources.has_key?( ref ) ) then
|
33
|
-
return !origin || !@_ResourceRefs || !@_ResourceRefs[ref] || !@_ResourceRefs[ref].has_key?(origin)
|
34
|
-
end
|
35
|
-
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
|
39
|
-
def checkRefs()
|
40
|
-
invalids = []
|
41
|
-
@_ResourceRefs = {}
|
42
|
-
if(@Resources) then
|
43
|
-
@Resources.keys.each do |resource|
|
44
|
-
@_ResourceRefs[resource.to_s] = @Resources[resource].references({})
|
45
|
-
end
|
46
|
-
@_ResourceRefs.keys.each do |origin|
|
47
|
-
@_ResourceRefs[origin].keys.each do |ref|
|
48
|
-
invalids.push "Invalid Reference: Resource #{origin} refers to #{ref}" unless isValidRef(ref,origin)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
outputRefs = {}
|
53
|
-
if(@Outputs) then
|
54
|
-
@Outputs.keys.each do |resource|
|
55
|
-
outputRefs[resource.to_s] = @Outputs[resource].references({})
|
56
|
-
end
|
57
|
-
outputRefs.keys.each do |origin|
|
58
|
-
outputRefs[origin].keys.each do |ref|
|
59
|
-
invalids.push "Invalid Reference: Output #{origin} refers to #{ref}" unless isValidRef(ref,nil)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
return invalids.length>0 ? invalids : nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class CloudFormationTemplate < OrchestrationTemplate
|
68
|
-
def self.template_types
|
69
|
-
CfnDsl::AWSTypes::AWS_Types
|
70
|
-
end
|
71
|
-
def self.type_module
|
72
|
-
CfnDsl::AWSTypes
|
73
|
-
end
|
74
|
-
|
75
|
-
names = {}
|
76
|
-
nametypes = {}
|
77
|
-
self.template_types["Resources"].each_pair do |name, type|
|
78
|
-
# Subclass ResourceDefintion and generate property methods
|
79
|
-
klass = Class.new(CfnDsl::ResourceDefinition)
|
80
|
-
klassname = name.split("::").join("_")
|
81
|
-
type_module.const_set( klassname, klass )
|
82
|
-
type["Properties"].each_pair do |pname, ptype|
|
83
|
-
if( ptype.instance_of? String )
|
84
|
-
create_klass = type_module.const_get( ptype );
|
85
|
-
|
86
|
-
klass.class_eval do
|
87
|
-
CfnDsl::methodNames(pname) do |method|
|
88
|
-
define_method(method) do |*values, &block|
|
89
|
-
if( values.length <1 ) then
|
90
|
-
values.push create_klass.new
|
91
|
-
end
|
92
|
-
@Properties ||= {}
|
93
|
-
@Properties[pname] = CfnDsl::PropertyDefinition.new( *values )
|
94
|
-
@Properties[pname].value.instance_eval &block if block
|
95
|
-
@Properties[pname].value
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
else
|
100
|
-
#Array version
|
101
|
-
sing_name = CfnDsl::Plurals.singularize( pname )
|
102
|
-
create_klass = type_module.const_get( ptype[0] )
|
103
|
-
klass.class_eval do
|
104
|
-
CfnDsl::methodNames(pname) do |method|
|
105
|
-
define_method(method) do |*values, &block|
|
106
|
-
if( values.length < 1 ) then
|
107
|
-
values.push []
|
108
|
-
end
|
109
|
-
@Properties ||= {}
|
110
|
-
@Properties[pname] ||= PropertyDefinition.new( *values )
|
111
|
-
@Properties[pname].value.instance_eval &block if block
|
112
|
-
@Properties[pname].value
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
CfnDsl::methodNames(sing_name) do |method|
|
117
|
-
define_method(method) do |value=nil, &block|
|
118
|
-
@Properties ||= {}
|
119
|
-
@Properties[pname] ||= PropertyDefinition.new( [] )
|
120
|
-
if( !value ) then
|
121
|
-
value = create_klass.new
|
122
|
-
end
|
123
|
-
@Properties[pname].value.push value
|
124
|
-
value.instance_eval &block if block
|
125
|
-
value
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
parts = name.split "::"
|
133
|
-
while( parts.length > 0)
|
134
|
-
abreve_name = parts.join "_"
|
135
|
-
if( names.has_key? abreve_name ) then
|
136
|
-
# this only happens if there is an ambiguity
|
137
|
-
names[abreve_name] = nil
|
138
|
-
else
|
139
|
-
names[abreve_name] = self.type_module.const_get(klassname)
|
140
|
-
nametypes[abreve_name] = name
|
141
|
-
end
|
142
|
-
parts.shift
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
|
148
|
-
#Define property setter methods for each of the unambiguous type names
|
149
|
-
names.each_pair do |typename,type|
|
150
|
-
if(type) then
|
151
|
-
class_eval do
|
152
|
-
CfnDsl::methodNames(typename) do |method|
|
153
|
-
define_method(method) do |name,*values,&block|
|
154
|
-
name = name.to_s
|
155
|
-
@Resources ||= {}
|
156
|
-
resource = @Resources[name] ||= type.new(*values)
|
157
|
-
resource.instance_eval &block if block
|
158
|
-
resource.instance_variable_set( "@Type", nametypes[typename] )
|
159
|
-
resource
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
end
|
168
|
-
|
169
|
-
class HeatTemplate < OrchestrationTemplate
|
170
|
-
def self.template_types
|
171
|
-
CfnDsl::OSTypes::OS_Types
|
172
|
-
end
|
173
|
-
def self.type_module
|
174
|
-
CfnDsl::OSTypes
|
175
|
-
end
|
176
|
-
|
177
|
-
names = {}
|
178
|
-
nametypes = {}
|
179
|
-
self.template_types["Resources"].each_pair do |name, type|
|
180
|
-
# Subclass ResourceDefintion and generate property methods
|
181
|
-
klass = Class.new(CfnDsl::ResourceDefinition)
|
182
|
-
klassname = name.split("::").join("_")
|
183
|
-
type_module.const_set( klassname, klass )
|
184
|
-
type["Properties"].each_pair do |pname, ptype|
|
185
|
-
if( ptype.instance_of? String )
|
186
|
-
create_klass = type_module.const_get( ptype );
|
187
|
-
|
188
|
-
klass.class_eval do
|
189
|
-
CfnDsl::methodNames(pname) do |method|
|
190
|
-
define_method(method) do |*values, &block|
|
191
|
-
if( values.length <1 ) then
|
192
|
-
values.push create_klass.new
|
193
|
-
end
|
194
|
-
@Properties ||= {}
|
195
|
-
@Properties[pname] = CfnDsl::PropertyDefinition.new( *values )
|
196
|
-
@Properties[pname].value.instance_eval &block if block
|
197
|
-
@Properties[pname].value
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
else
|
202
|
-
#Array version
|
203
|
-
sing_name = CfnDsl::Plurals.singularize( pname )
|
204
|
-
create_klass = type_module.const_get( ptype[0] )
|
205
|
-
klass.class_eval do
|
206
|
-
CfnDsl::methodNames(pname) do |method|
|
207
|
-
define_method(method) do |*values, &block|
|
208
|
-
if( values.length < 1 ) then
|
209
|
-
values.push []
|
210
|
-
end
|
211
|
-
@Properties ||= {}
|
212
|
-
@Properties[pname] ||= PropertyDefinition.new( *values )
|
213
|
-
@Properties[pname].value.instance_eval &block if block
|
214
|
-
@Properties[pname].value
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
CfnDsl::methodNames(sing_name) do |method|
|
219
|
-
define_method(method) do |value=nil, &block|
|
220
|
-
@Properties ||= {}
|
221
|
-
@Properties[pname] ||= PropertyDefinition.new( [] )
|
222
|
-
if( !value ) then
|
223
|
-
value = create_klass.new
|
224
|
-
end
|
225
|
-
@Properties[pname].value.push value
|
226
|
-
value.instance_eval &block if block
|
227
|
-
value
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
end
|
234
|
-
parts = name.split "::"
|
235
|
-
while( parts.length > 0)
|
236
|
-
abreve_name = parts.join "_"
|
237
|
-
if( names.has_key? abreve_name ) then
|
238
|
-
# this only happens if there is an ambiguity
|
239
|
-
names[abreve_name] = nil
|
240
|
-
else
|
241
|
-
names[abreve_name] = self.type_module.const_get(klassname)
|
242
|
-
nametypes[abreve_name] = name
|
243
|
-
end
|
244
|
-
parts.shift
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
#Define property setter methods for each of the unambiguous type names
|
249
|
-
names.each_pair do |typename,type|
|
250
|
-
if(type) then
|
251
|
-
class_eval do
|
252
|
-
CfnDsl::methodNames(typename) do |method|
|
253
|
-
define_method(method) do |name,*values,&block|
|
254
|
-
name = name.to_s
|
255
|
-
@Resources ||= {}
|
256
|
-
resource = @Resources[name] ||= type.new(*values)
|
257
|
-
resource.instance_eval &block if block
|
258
|
-
resource.instance_variable_set( "@Type", nametypes[typename] )
|
259
|
-
resource
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'cfndsl/JSONable'
|
2
|
-
|
3
|
-
module CfnDsl
|
4
|
-
class CreationPolicyDefinition < JSONable
|
5
|
-
##
|
6
|
-
# Handles creation policy objects for Resources
|
7
|
-
#
|
8
|
-
# Usage
|
9
|
-
# Resource("aaa") {
|
10
|
-
# CreationPolicy('ResourceSignal', { 'Count' => 1, 'Timeout' => 'PT10M' })
|
11
|
-
# }
|
12
|
-
#
|
13
|
-
def initialize(value)
|
14
|
-
@value = value;
|
15
|
-
end
|
16
|
-
|
17
|
-
def value
|
18
|
-
return @value
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_json(*a)
|
22
|
-
@value.to_json(*a)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/cfndsl/Errors.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module CfnDsl
|
2
|
-
module Errors
|
3
|
-
@@errors = []
|
4
|
-
|
5
|
-
def self.error( err, idx=nil )
|
6
|
-
if(idx.nil?) then
|
7
|
-
@@errors.push ( err + "\n" + caller.join("\n") + "\n" )
|
8
|
-
else
|
9
|
-
if( m = caller[idx].match(/^.*?:\d+:/ ) ) then
|
10
|
-
err_loc = m[0];
|
11
|
-
else
|
12
|
-
err_loc = caller[idx]
|
13
|
-
end
|
14
|
-
|
15
|
-
@@errors.push ( err_loc + " " + err + "\n" )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.clear()
|
20
|
-
@@errors = []
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.errors()
|
24
|
-
@@errors
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.errors?()
|
28
|
-
return @@errors.length > 0
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|