convection 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/convection.gemspec +2 -2
- data/lib/convection/version.rb +0 -2
- metadata +4 -251
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e1a5604f949a9fe05e8889deb5f0b00aa52307
|
4
|
+
data.tar.gz: 1bbc1d882ac5bc4780e274b8f8b6dcbaf1b9d834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbee68d7503bf6def7ce8a689404d19fefba9dcdaea255ac5abaeb418f66f94b690b1257f98d7eff1387220a085e32fde6f7a6cca65337bb2b2822b0e3815320
|
7
|
+
data.tar.gz: 019a281498278e5fdb0489f9489aab52ec957c986cca0be41f82b9873296d3af27c58ae07a0daabdfb2f35d601a78a0e32983d377b91c5c78f9b0c5d164d1ed1
|
data/convection.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Convection::VERSION
|
9
9
|
spec.authors = ['John Manero']
|
10
10
|
spec.email = ['jmanero@rapid7.com']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = %q{A fully generic, modular DSL for AWS CloudFormation}
|
12
|
+
spec.description = %q{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.}
|
13
13
|
spec.homepage = 'https://github.com/rapid7/convection'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
data/lib/convection/version.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# nodoc
|
2
2
|
module Convection
|
3
3
|
VERSION = IO.read(File.expand_path('../../../VERSION', __FILE__)) rescue '0.0.1'
|
4
|
-
SUMMARY = 'A fully generic, modular DSL for AWS CloudFormation'.freeze
|
5
|
-
DESCRIPTION = IO.read(File.expand_path('../../../README.md', __FILE__)) rescue ''
|
6
4
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
@@ -66,256 +66,9 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.19'
|
69
|
-
description:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
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.
|
74
|
-
|
75
|
-
## Version 0.0.1
|
76
|
-
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.
|
77
|
-
|
78
|
-
## Installation
|
79
|
-
Add this line to your application's Gemfile:
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
gem 'convection'
|
83
|
-
```
|
84
|
-
|
85
|
-
And then execute:
|
86
|
-
|
87
|
-
$ bundle
|
88
|
-
|
89
|
-
Or install it yourself as:
|
90
|
-
|
91
|
-
$ gem install convection
|
92
|
-
|
93
|
-
## Template DSL
|
94
|
-
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:
|
95
|
-
|
96
|
-
```ruby
|
97
|
-
require 'convection'
|
98
|
-
|
99
|
-
## Create a new instance of Convection::Model::Template
|
100
|
-
Convection.template do
|
101
|
-
description 'An example template'
|
102
|
-
|
103
|
-
parameter 'InstanceSize' do
|
104
|
-
type 'String'
|
105
|
-
description 'Instance Size'
|
106
|
-
default 'm3.medium'
|
107
|
-
|
108
|
-
allow 'm3.medium'
|
109
|
-
allow 'm3.large'
|
110
|
-
allow 'm3.xlarge'
|
111
|
-
end
|
112
|
-
|
113
|
-
## The `resource` method can be used to define any resource
|
114
|
-
## supported by CloudFormation: See http://docs.aws.amazon.com/\
|
115
|
-
## AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
|
116
|
-
resource 'AnEC2Instance' do
|
117
|
-
type 'AWS::EC2::Instance'
|
118
|
-
property 'AvailabilityZone', 'us-east-1a'
|
119
|
-
property 'ImageId', 'ami-76e27e1e' ## Ubuntu 14.04 hvm:ebs
|
120
|
-
property 'KeyName', 'test'
|
121
|
-
property 'SecurityGroupIds', ['sg-dd733c41', 'sg-dd738df3']
|
122
|
-
property 'Tags', [{
|
123
|
-
'Key' => 'Name',
|
124
|
-
'Value' => 'test-1'
|
125
|
-
}]
|
126
|
-
|
127
|
-
property 'DisableApiTermination', false
|
128
|
-
end
|
129
|
-
|
130
|
-
## `ec2_instnce` extends `resource`. The following results in JSON
|
131
|
-
## identical to that of Resource[AnEC2Instance]
|
132
|
-
ec2_instance 'AnOtherInstance' do
|
133
|
-
availability_zone 'us-east-1a'
|
134
|
-
image_id 'ami-76e27e1e'
|
135
|
-
key_name 'test'
|
136
|
-
|
137
|
-
security_group 'sg-dd733c41'
|
138
|
-
security_group 'sg-dd738df3'
|
139
|
-
|
140
|
-
tag 'Name', 'test-2'
|
141
|
-
|
142
|
-
## All of the methods of the `resource` primative are available in
|
143
|
-
## its children:
|
144
|
-
property 'DisableApiTermination', false
|
145
|
-
end
|
146
|
-
end.to_json
|
147
|
-
```
|
148
|
-
|
149
|
-
### Parameters
|
150
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
|
151
|
-
|
152
|
-
```ruby
|
153
|
-
parameter 'InstanceType' do
|
154
|
-
type 'String'
|
155
|
-
description 'Set the thing\'s instance flavor'
|
156
|
-
default 'm3.medium'
|
157
|
-
|
158
|
-
allow 'm3.medium'
|
159
|
-
allow 'm3.large'
|
160
|
-
allow 'm3.xlarge'
|
161
|
-
end
|
162
|
-
```
|
163
|
-
|
164
|
-
### Mappings
|
165
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
|
166
|
-
|
167
|
-
```ruby
|
168
|
-
mapping 'RegionalAMIs' do
|
169
|
-
item 'us-east-1', 'hvm', 'ami-76e27e1e'
|
170
|
-
item 'us-west-1', 'hvm', 'ami-d5180890'
|
171
|
-
item 'us-east-1', 'pv', 'ami-64e27e0c'
|
172
|
-
item 'us-west-1', 'pv', 'ami-c5180880'
|
173
|
-
end
|
174
|
-
```
|
175
|
-
|
176
|
-
### Conditions
|
177
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
|
178
|
-
|
179
|
-
```ruby
|
180
|
-
condition 'ThisCondition' do
|
181
|
-
fn_equals( fn_ref('SomeParameter'), 'value_x' )
|
182
|
-
end
|
183
|
-
|
184
|
-
condition 'ThatCondition' do
|
185
|
-
fn_or(
|
186
|
-
fn_equals( fn_ref('SomeParameter'), 'value_y' ),
|
187
|
-
fn_equals( fn_ref('SomeParameter'), 'value_z' )
|
188
|
-
)
|
189
|
-
end
|
190
|
-
```
|
191
|
-
|
192
|
-
### Resources
|
193
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
|
194
|
-
|
195
|
-
```ruby
|
196
|
-
resource 'AnInstance' do
|
197
|
-
type 'AWS::EC2::Instance'
|
198
|
-
|
199
|
-
## Optional condition reference
|
200
|
-
condition 'SomeCondition'
|
201
|
-
|
202
|
-
## Add Resource Properties
|
203
|
-
property 'AvailabilityZone', 'us-east-1a'
|
204
|
-
property 'ImageId', 'ami-76e27e1e' ## Ubuntu 14.04 hvm:ebs
|
205
|
-
property 'KeyName', 'test'
|
206
|
-
...
|
207
|
-
end
|
208
|
-
```
|
209
|
-
|
210
|
-
Using a condition to set a resource property:
|
211
|
-
|
212
|
-
```ruby
|
213
|
-
resource 'MySQL' do
|
214
|
-
type 'AWS::RDS::DBInstance'
|
215
|
-
...
|
216
|
-
property 'Iops', fn_if('ThisCondition', '1000', fn_ref('AWS::NoValue'))
|
217
|
-
...
|
218
|
-
end
|
219
|
-
```
|
220
|
-
|
221
|
-
### Outputs
|
222
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
|
223
|
-
|
224
|
-
```ruby
|
225
|
-
output 'SomeName' do
|
226
|
-
description 'An Important Attribute'
|
227
|
-
value get_att('Resource', 'Attribute')
|
228
|
-
|
229
|
-
## Optional condition reference
|
230
|
-
condition 'SomeCondition'
|
231
|
-
end
|
232
|
-
```
|
233
|
-
|
234
|
-
### Intrinsic Functions
|
235
|
-
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
|
236
|
-
|
237
|
-
All intrinsic functions are available as helper methods:
|
238
|
-
|
239
|
-
* base64(content)
|
240
|
-
* fn_and(conditions...)
|
241
|
-
* fn_equals(value_1, value_2)
|
242
|
-
* fn_if(condition, value_true, value_false)
|
243
|
-
* fn_not(condition)
|
244
|
-
* fn_or(conditions...)
|
245
|
-
* find_in_map(map_name, key_1, key_2)
|
246
|
-
* get_att(resource, attr_name)
|
247
|
-
* get_azs(region)
|
248
|
-
* join(delimiter, values...)
|
249
|
-
* select(index, objects...)
|
250
|
-
* fn_ref(resource)
|
251
|
-
|
252
|
-
```ruby
|
253
|
-
ec2_instance "TestInstanceFoo#{ i }" do
|
254
|
-
image_id find_in_map('RegionalAMIs', fn_ref('AWS::Region'), 'hvm')
|
255
|
-
instance_type 'm3.medium'
|
256
|
-
key_name find_in_map('RegionalKeys', fn_ref('AWS::Region'), 'test')
|
257
|
-
security_group fn_ref('LousySecurityGroup')
|
258
|
-
subnet fn_ref("TestSubnet")
|
259
|
-
end
|
260
|
-
```
|
261
|
-
|
262
|
-
## Stack Control
|
263
|
-
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.
|
264
|
-
|
265
|
-
### Class `Convection::Control::Stack`
|
266
|
-
* `.new(name, template, options = {})`
|
267
|
-
* _name_ CloudFormation Stack name
|
268
|
-
* _template_ Instance of Convection::Model::Template
|
269
|
-
* _options_ - Hash
|
270
|
-
* _region_ - AWS region, format `us-east-1`. Default us-east-1
|
271
|
-
* _credentials_ - Optional instance of AWS::Credentials. See the [AWS-SDK Documentation](http://docs.aws.amazon.com/sdkforruby/api/frames.html)
|
272
|
-
* _parameters_ - Stack parameters, as a `Hash` of `{ key => value }`
|
273
|
-
* _tags_ - Stack tags, as a `Hash` of `{ key => value }`
|
274
|
-
* _on_failure_ - Create failure action. Default `DELETE`
|
275
|
-
* _capabilities_ - See the [AWS-SDK Documentation](http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#create_stack-instance_method)
|
276
|
-
* Additional options will be passed directly to `create_stack` and `update_stack`
|
277
|
-
|
278
|
-
* `#status` - Returns the stack status
|
279
|
-
* `#exist?` - Returns true if the stack exists and is not in a DELETED state
|
280
|
-
* `#complete?`
|
281
|
-
* `#rollback?`
|
282
|
-
* `#fail?`
|
283
|
-
* `#render` - Populates the provided template with any environment data included in the stack (e.g. availability zones). Returns a `Hash`
|
284
|
-
* `#to_json` - Render template and transofrm to a pretty-generated JSON `String`
|
285
|
-
* `#apply` - Renter template and create/update CloudFormation Stack
|
286
|
-
* `#delete` - Delete CloudFormation Stack
|
287
|
-
* `#availability_zones(&block)` - Return an array of strings representing the region's availability zones. Provided codeblock will be called for each AZ.
|
288
|
-
|
289
|
-
## Futures
|
290
|
-
*
|
291
|
-
|
292
|
-
## License
|
293
|
-
_Copyright (c) 2015 John Manero, Rapid7 LLC._
|
294
|
-
|
295
|
-
```
|
296
|
-
MIT License
|
297
|
-
===========
|
298
|
-
|
299
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
300
|
-
a copy of this software and associated documentation files (the
|
301
|
-
"Software"), to deal in the Software without restriction, including
|
302
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
303
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
304
|
-
permit persons to whom the Software is furnished to do so, subject to
|
305
|
-
the following conditions:
|
306
|
-
|
307
|
-
The above copyright notice and this permission notice shall be
|
308
|
-
included in all copies or substantial portions of the Software.
|
309
|
-
|
310
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
311
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
312
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
313
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
314
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
315
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
316
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
317
|
-
|
318
|
-
```
|
69
|
+
description: This gem aims to provide a reusable model for AWS CloudFormation in Ruby.
|
70
|
+
It exposes a DSL for template definition, and a simple, decoupled abstraction of
|
71
|
+
a CloudFormation Stack to compile and apply templates.
|
319
72
|
email:
|
320
73
|
- jmanero@rapid7.com
|
321
74
|
executables:
|