convection 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE +23 -0
- data/README.md +224 -0
- data/Rakefile +2 -0
- data/Thorfile +5 -0
- data/convection.gemspec +27 -0
- data/example/iam_role.rb +63 -0
- data/example/s3.rb +13 -0
- data/example/vpc.rb +85 -0
- data/lib/convection.rb +18 -0
- data/lib/convection/control/stack.rb +165 -0
- data/lib/convection/dsl/helpers.rb +15 -0
- data/lib/convection/dsl/intrinsic_functions.rb +79 -0
- data/lib/convection/model/mixin/cidr_block.rb +17 -0
- data/lib/convection/model/mixin/conditional.rb +21 -0
- data/lib/convection/model/mixin/taggable.rb +48 -0
- data/lib/convection/model/template.rb +127 -0
- data/lib/convection/model/template/mapping.rb +42 -0
- data/lib/convection/model/template/output.rb +37 -0
- data/lib/convection/model/template/parameter.rb +44 -0
- data/lib/convection/model/template/resource.rb +64 -0
- data/lib/convection/model/template/resource/aws_ec2_instance.rb +69 -0
- data/lib/convection/model/template/resource/aws_ec2_internet_gateway.rb +55 -0
- data/lib/convection/model/template/resource/aws_ec2_route.rb +55 -0
- data/lib/convection/model/template/resource/aws_ec2_route_table.rb +60 -0
- data/lib/convection/model/template/resource/aws_ec2_security_group.rb +104 -0
- data/lib/convection/model/template/resource/aws_ec2_subnet.rb +66 -0
- data/lib/convection/model/template/resource/aws_ec2_subnet_route_table_association.rb +39 -0
- data/lib/convection/model/template/resource/aws_ec2_vpc.rb +116 -0
- data/lib/convection/model/template/resource/aws_ec2_vpc_gateway_attachment.rb +43 -0
- data/lib/convection/model/template/resource/aws_iam_policy.rb +45 -0
- data/lib/convection/model/template/resource/aws_iam_role.rb +45 -0
- data/lib/convection/model/template/resource/aws_s3_bucket.rb +67 -0
- data/lib/convection/model/template/resource/aws_s3_bucket_policy.rb +40 -0
- data/lib/convection/version.rb +6 -0
- metadata +375 -0
metadata
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Manero
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor-scmversion
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - <
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - <
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: netaddr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.5.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.5.0
|
83
|
+
description: |
|
84
|
+
# Convection
|
85
|
+
_A fully generic, modular DSL for AWS CloudFormation_
|
86
|
+
|
87
|
+
This gem aims to provide a reusable model for AWS CloudFormation in Ruby. It exposes a DSL for template definition, and a simple, decoupled abstraction of a CloudFormation Stack to compile and apply templates.
|
88
|
+
|
89
|
+
## Version 0.0.1
|
90
|
+
This is an Alpha release. It is still lacking functionality and testing. We plan to develop/improve features as we begin to use it for our own deployments in the coming months. PRs welcome.
|
91
|
+
|
92
|
+
## Installation
|
93
|
+
Add this line to your application's Gemfile:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
gem 'convection'
|
97
|
+
```
|
98
|
+
|
99
|
+
And then execute:
|
100
|
+
|
101
|
+
$ bundle
|
102
|
+
|
103
|
+
Or install it yourself as:
|
104
|
+
|
105
|
+
$ gem install convection
|
106
|
+
|
107
|
+
## Template DSL
|
108
|
+
The core DSL provides all of the available JSON primatives of CloudFormation in the form of ruby methods. These primatives are used to compose higher-order methods for commonly used definitions:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
require 'convection'
|
112
|
+
|
113
|
+
## Create a new instance of Convection::Model::Template
|
114
|
+
Convection.template do
|
115
|
+
description 'An example template'
|
116
|
+
|
117
|
+
parameter 'InstanceSize' do
|
118
|
+
type 'String'
|
119
|
+
description 'Instance Size'
|
120
|
+
default 'm3.medium'
|
121
|
+
|
122
|
+
allow 'm3.medium'
|
123
|
+
allow 'm3.large'
|
124
|
+
allow 'm3.xlarge'
|
125
|
+
end
|
126
|
+
|
127
|
+
## The `resource` method can be used to define any resource
|
128
|
+
## supported by CloudFormation: See http://docs.aws.amazon.com/\
|
129
|
+
## AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
|
130
|
+
resource 'AnEC2Instance' do
|
131
|
+
type 'AWS::EC2::Instance'
|
132
|
+
property 'AvailabilityZone', 'us-east-1a'
|
133
|
+
property 'ImageId', 'ami-76e27e1e' ## Ubuntu 14.04 hvm:ebs
|
134
|
+
property 'KeyName', 'test'
|
135
|
+
property 'SecurityGroupIds', ['sg-dd733c41', 'sg-dd738df3']
|
136
|
+
property 'Tags', [{
|
137
|
+
'Key' => 'Name',
|
138
|
+
'Value' => 'test-1'
|
139
|
+
}]
|
140
|
+
|
141
|
+
property 'DisableApiTermination', false
|
142
|
+
end
|
143
|
+
|
144
|
+
## `ec2_instnce` extends `resource`. The following results in JSON
|
145
|
+
## identical to that of Resource[AnEC2Instance]
|
146
|
+
ec2_instance 'AnOtherInstance' do
|
147
|
+
availability_zone 'us-east-1a'
|
148
|
+
image_id 'ami-76e27e1e'
|
149
|
+
key_name 'test'
|
150
|
+
|
151
|
+
security_group 'sg-dd733c41'
|
152
|
+
security_group 'sg-dd738df3'
|
153
|
+
|
154
|
+
tag 'Name', 'test-2'
|
155
|
+
|
156
|
+
## All of the methods of the `resource` primative are available in
|
157
|
+
## its children:
|
158
|
+
property 'DisableApiTermination', false
|
159
|
+
end
|
160
|
+
end.to_json
|
161
|
+
```
|
162
|
+
|
163
|
+
### Parameters
|
164
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
parameter 'InstanceType' do
|
168
|
+
type 'String'
|
169
|
+
description 'Set the thing\'s instance flavor'
|
170
|
+
default 'm3.medium'
|
171
|
+
|
172
|
+
allow 'm3.medium'
|
173
|
+
allow 'm3.large'
|
174
|
+
allow 'm3.xlarge'
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
### Mappings
|
179
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
mapping 'RegionalAMIs' do
|
183
|
+
item 'us-east-1', 'hvm', 'ami-76e27e1e'
|
184
|
+
item 'us-west-1', 'hvm', 'ami-d5180890'
|
185
|
+
item 'us-east-1', 'pv', 'ami-64e27e0c'
|
186
|
+
item 'us-west-1', 'pv', 'ami-c5180880'
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
### Conditions
|
191
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
|
192
|
+
|
193
|
+
Not implemented yet.
|
194
|
+
|
195
|
+
### Resources
|
196
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
resource 'AnInstance' do
|
200
|
+
type 'AWS::EC2::Instance'
|
201
|
+
|
202
|
+
## Optional condition reference
|
203
|
+
condition 'SomeCondition'
|
204
|
+
|
205
|
+
## Add Resource Properties
|
206
|
+
property 'AvailabilityZone', 'us-east-1a'
|
207
|
+
property 'ImageId', 'ami-76e27e1e' ## Ubuntu 14.04 hvm:ebs
|
208
|
+
property 'KeyName', 'test'
|
209
|
+
...
|
210
|
+
end
|
211
|
+
```
|
212
|
+
|
213
|
+
### Outputs
|
214
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
output 'SomeName' do
|
218
|
+
description 'An Important Attribute'
|
219
|
+
value get_att('Resource', 'Attribute')
|
220
|
+
|
221
|
+
## Optional condition reference
|
222
|
+
condition 'SomeCondition'
|
223
|
+
end
|
224
|
+
```
|
225
|
+
|
226
|
+
### Intrinsic Functions
|
227
|
+
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
|
228
|
+
|
229
|
+
All intrinsic functions are available as helper methods:
|
230
|
+
|
231
|
+
* base64(content)
|
232
|
+
* fn_and(conditions...)
|
233
|
+
* fn_equals(value_1, value_2)
|
234
|
+
* fn_if(condition, value_true, value_false)
|
235
|
+
* fn_not(condition)
|
236
|
+
* fn_or(conditions...)
|
237
|
+
* find_in_map(map_name, key_1, key_2)
|
238
|
+
* get_att(resource, attr_name)
|
239
|
+
* get_azs(region)
|
240
|
+
* join(delimiter, values...)
|
241
|
+
* select(index, objects...)
|
242
|
+
* fn_ref(resource)
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
ec2_instance "TestInstanceFoo#{ i }" do
|
246
|
+
image_id find_in_map('RegionalAMIs', fn_ref('AWS::Region'), 'hvm')
|
247
|
+
instance_type 'm3.medium'
|
248
|
+
key_name find_in_map('RegionalKeys', fn_ref('AWS::Region'), 'test')
|
249
|
+
security_group fn_ref('LousySecurityGroup')
|
250
|
+
subnet fn_ref("TestSubnet")
|
251
|
+
end
|
252
|
+
```
|
253
|
+
|
254
|
+
## Stack Control
|
255
|
+
The `Stack` class provides a state wrapper for CloudFormation Stacks. It tracks the state of the managed stack, and creates/updates accordingly. `Stack` is also region-aware, and can be used within a template to define resources that depend upon availability-zones or other region-specific neuances that cannot be represented as maps or require iteration.
|
256
|
+
|
257
|
+
### Class `Convection::Control::Stack`
|
258
|
+
* `.new(name, template, options = {})`
|
259
|
+
* _name_ CloudFormation Stack name
|
260
|
+
* _template_ Instance of Convection::Model::Template
|
261
|
+
* _options_ - Hash
|
262
|
+
* _region_ - AWS region, format `us-east-1`. Default us-east-1
|
263
|
+
* _credentials_ - Optional instance of AWS::Credentials. See the [AWS-SDK Documentation](http://docs.aws.amazon.com/sdkforruby/api/frames.html)
|
264
|
+
* _parameters_ - Stack parameters, as a `Hash` of `{ key => value }`
|
265
|
+
* _tags_ - Stack tags, as a `Hash` of `{ key => value }`
|
266
|
+
* _on_failure_ - Create failure action. Default `DELETE`
|
267
|
+
* _capabilities_ - See the [AWS-SDK Documentation](http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#create_stack-instance_method)
|
268
|
+
* Additional options will be passed directly to `create_stack` and `update_stack`
|
269
|
+
|
270
|
+
* `#status` - Returns the stack status
|
271
|
+
* `#exist?` - Returns true if the stack exists and is not in a DELETED state
|
272
|
+
* `#complete?`
|
273
|
+
* `#rollback?`
|
274
|
+
* `#fail?`
|
275
|
+
* `#render` - Populates the provided template with any environment data included in the stack (e.g. availability zones). Returns a `Hash`
|
276
|
+
* `#to_json` - Render template and transofrm to a pretty-generated JSON `String`
|
277
|
+
* `#apply` - Renter template and create/update CloudFormation Stack
|
278
|
+
* `#delete` - Delete CloudFormation Stack
|
279
|
+
* `#availability_zones(&block)` - Return an array of strings representing the region's availability zones. Provided codeblock will be called for each AZ.
|
280
|
+
|
281
|
+
## License
|
282
|
+
_Copyright (c) 2015 John Manero, Rapid7 LLC._
|
283
|
+
|
284
|
+
```
|
285
|
+
MIT License
|
286
|
+
===========
|
287
|
+
|
288
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
289
|
+
a copy of this software and associated documentation files (the
|
290
|
+
"Software"), to deal in the Software without restriction, including
|
291
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
292
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
293
|
+
permit persons to whom the Software is furnished to do so, subject to
|
294
|
+
the following conditions:
|
295
|
+
|
296
|
+
The above copyright notice and this permission notice shall be
|
297
|
+
included in all copies or substantial portions of the Software.
|
298
|
+
|
299
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
300
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
301
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
302
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
303
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
304
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
305
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
306
|
+
|
307
|
+
```
|
308
|
+
email:
|
309
|
+
- jmanero@rapid7.com
|
310
|
+
executables: []
|
311
|
+
extensions: []
|
312
|
+
extra_rdoc_files: []
|
313
|
+
files:
|
314
|
+
- .gitignore
|
315
|
+
- .rubocop.yml
|
316
|
+
- Gemfile
|
317
|
+
- LICENSE
|
318
|
+
- README.md
|
319
|
+
- Rakefile
|
320
|
+
- Thorfile
|
321
|
+
- convection.gemspec
|
322
|
+
- example/iam_role.rb
|
323
|
+
- example/s3.rb
|
324
|
+
- example/vpc.rb
|
325
|
+
- lib/convection.rb
|
326
|
+
- lib/convection/control/stack.rb
|
327
|
+
- lib/convection/dsl/helpers.rb
|
328
|
+
- lib/convection/dsl/intrinsic_functions.rb
|
329
|
+
- lib/convection/model/mixin/cidr_block.rb
|
330
|
+
- lib/convection/model/mixin/conditional.rb
|
331
|
+
- lib/convection/model/mixin/taggable.rb
|
332
|
+
- lib/convection/model/template.rb
|
333
|
+
- lib/convection/model/template/mapping.rb
|
334
|
+
- lib/convection/model/template/output.rb
|
335
|
+
- lib/convection/model/template/parameter.rb
|
336
|
+
- lib/convection/model/template/resource.rb
|
337
|
+
- lib/convection/model/template/resource/aws_ec2_instance.rb
|
338
|
+
- lib/convection/model/template/resource/aws_ec2_internet_gateway.rb
|
339
|
+
- lib/convection/model/template/resource/aws_ec2_route.rb
|
340
|
+
- lib/convection/model/template/resource/aws_ec2_route_table.rb
|
341
|
+
- lib/convection/model/template/resource/aws_ec2_security_group.rb
|
342
|
+
- lib/convection/model/template/resource/aws_ec2_subnet.rb
|
343
|
+
- lib/convection/model/template/resource/aws_ec2_subnet_route_table_association.rb
|
344
|
+
- lib/convection/model/template/resource/aws_ec2_vpc.rb
|
345
|
+
- lib/convection/model/template/resource/aws_ec2_vpc_gateway_attachment.rb
|
346
|
+
- lib/convection/model/template/resource/aws_iam_policy.rb
|
347
|
+
- lib/convection/model/template/resource/aws_iam_role.rb
|
348
|
+
- lib/convection/model/template/resource/aws_s3_bucket.rb
|
349
|
+
- lib/convection/model/template/resource/aws_s3_bucket_policy.rb
|
350
|
+
- lib/convection/version.rb
|
351
|
+
homepage: ''
|
352
|
+
licenses:
|
353
|
+
- MIT
|
354
|
+
metadata: {}
|
355
|
+
post_install_message:
|
356
|
+
rdoc_options: []
|
357
|
+
require_paths:
|
358
|
+
- lib
|
359
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
360
|
+
requirements:
|
361
|
+
- - '>='
|
362
|
+
- !ruby/object:Gem::Version
|
363
|
+
version: '0'
|
364
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
365
|
+
requirements:
|
366
|
+
- - '>='
|
367
|
+
- !ruby/object:Gem::Version
|
368
|
+
version: '0'
|
369
|
+
requirements: []
|
370
|
+
rubyforge_project:
|
371
|
+
rubygems_version: 2.0.14
|
372
|
+
signing_key:
|
373
|
+
specification_version: 4
|
374
|
+
summary: A fully generic, modular DSL for AWS CloudFormation
|
375
|
+
test_files: []
|