sfn 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +320 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f7d923b3e2232d313f37902aba52368d3feb60c
4
+ data.tar.gz: b3821d0d8663923f23e083ff8938fc0f9a2f9942
5
+ SHA512:
6
+ metadata.gz: 7d4ca8056ea8efd86b023255627edaa76c455604ef33406f053a78b4b9ec5837aa0ec650b1ce6b290a64fbe83819529c2a8671a9ae612c6b073511c2f99f5356
7
+ data.tar.gz: 3428daa388483853cce8be81bd0ef39e4ff87a3e7d19cbacf01a318bb2b0d46dd9e31dacfb8ff9885f4f85aef67e256bea78352ef714267a460f3b7985913026
@@ -0,0 +1,320 @@
1
+ # Knife CloudFormation
2
+
3
+ This is a plugin for the `knife` command provided by
4
+ Chef to interact with AWS (and other) orchestration
5
+ APIs.
6
+
7
+ ## API Compatibility
8
+
9
+ * AWS
10
+ * Rackspace
11
+ * OpenStack
12
+
13
+ ## Configuration
14
+
15
+ The easiest way to configure the plugin is via the
16
+ `knife.rb` file. Credentials are the only configuration
17
+ requirement, and the `Hash` provided is proxied to
18
+ [Miasma][miasma]:
19
+
20
+ ### AWS
21
+
22
+ ```ruby
23
+ # .chef/knife.rb
24
+
25
+ knife[:cloudformation][:credentials] = {
26
+ :provider => :aws,
27
+ :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
28
+ :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
29
+ :aws_region => ENV['AWS_REGION']
30
+ }
31
+ ```
32
+
33
+ ### Rackspace
34
+
35
+ ```ruby
36
+ # .chef/knife.rb
37
+
38
+ knife[:cloudformation][:credentials] = {
39
+ :provider => :rackspace,
40
+ :rackspace_username => ENV['RACKSPACE_USERNAME'],
41
+ :rackspace_api_key => ENV['RACKSPACE_API_KEY'],
42
+ :rackspace_region => ENV['RACKSPACE_REGION']
43
+ }
44
+ ```
45
+
46
+ ### OpenStack
47
+
48
+ ```ruby
49
+ # .chef/knife.rb
50
+
51
+ knife[:cloudformation][:credentials] = {
52
+ :provider => :open_stack,
53
+ :open_stack_username => ENV['OPENSTACK_USERNAME'],
54
+ :open_stack_password => ENV['OPENSTACK_PASSWORD'],
55
+ :open_stack_identity_url => ENV['OPENSTACK_IDENTITY_URL'],
56
+ :open_stack_tenant_name => ENV['OPENSTACK_TENANT']
57
+ }
58
+ ```
59
+
60
+ ## Commands
61
+
62
+ * `knife cloudformation list`
63
+ * `knife cloudformation create`
64
+ * `knife cloudformation update`
65
+ * `knife cloudformation destroy`
66
+ * `knife cloudformation events`
67
+ * `knife cloudformation describe`
68
+ * `knife cloudformation inspect`
69
+ * `knife cloudformation validate`
70
+
71
+ ### `knife cloudformation list`
72
+
73
+ Provides listing of current stacks and state of each stack.
74
+
75
+ #### Supported options
76
+
77
+ * `--attribute ATTR` stack attribute to display
78
+ * `--status STATUS` match stacks with given status
79
+
80
+ ### `knife cloudformation validate`
81
+
82
+ Validates template with API
83
+
84
+ #### Supported options
85
+
86
+ * `--[no-]processing` enable template processing
87
+ * `--file PATH` path to stack template file
88
+ * `--translate PROVIDER` translate template to provider
89
+ * `--[no-]apply-nesting` apply template nesting logic
90
+ * `--nesting-bucket BUCKET` asset store bucket to place nested stack templates
91
+
92
+ ### `knife cloudformation create NAME`
93
+
94
+ Creates a new stack with the provided name (`NAME`).
95
+
96
+ #### Supported options
97
+
98
+ * `--timeout MINUTES` stack creation timeout limit
99
+ * `--[no-]rollback` disable rollback on failure
100
+ * `--capability CAPABILITY` enable capability within API
101
+ * `--notifications ARN` add notification ARN
102
+ * `--print-only` print stack template JSON and exit
103
+ * `--apply-stack NAME` apply existing stack outputs
104
+ * `--[no-]processing` enable template processing
105
+ * `--file PATH` path to stack template file
106
+ * `--translate PROVIDER` translate template to provider
107
+ * `--[no-]apply-nesting` apply template nesting logic
108
+ * `--nesting-bucket BUCKET` asset store bucket to place nested stack templates
109
+
110
+ #### Apply Stacks
111
+
112
+ The `--apply-stack` option allows providing the name of an existing
113
+ stack when creating or updating. Applying stacks is simply fetching
114
+ the outputs from the applied stacks and automatically defaulting the
115
+ set parameter of the new or updated stack. Outputs are matched
116
+ by name to the parameters of the target stack. This allows an easy
117
+ way to use values from existing stacks when building new stacks.
118
+
119
+ Example:
120
+
121
+ StackA:
122
+
123
+ ```json
124
+ ...
125
+ "Outputs": {
126
+ "LoadBalancerAddress": {
127
+ "Description": "Address of Load Balancer",
128
+ "Value": {
129
+ "Fn::GetAtt": [
130
+ "LoadBalancerResource",
131
+ "DNSName"
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ ...
137
+ ```
138
+
139
+ StackB:
140
+
141
+ ```json
142
+ ...
143
+ "Parameters": {
144
+ "LoadBalancerAddress": {
145
+ "Type": "String",
146
+ "Default": "unset"
147
+ }
148
+ }
149
+ ...
150
+ ```
151
+
152
+ When creating StackB, if we use the `--apply-stack` option:
153
+
154
+ ```
155
+ $ knife cloudformation create StackB --apply-stack StackA
156
+ ```
157
+
158
+ when prompted for the stack parameters, we will find the parameter
159
+ value for `LoadBalancerAddress` to be filled in with the output
160
+ provided from StackA.
161
+
162
+ #### Processing
163
+
164
+ The default behavior of this plugin assumes templates will be
165
+ in JSON format. The `--processing` flag will allow providing Ruby
166
+ files to dynamically generate templates using the SparkleFormation
167
+ library.
168
+
169
+ _NOTE: (SparkleFormation Usage Documentation)[]._
170
+
171
+ This plugin supports the advanced stack nesting feature provided by
172
+ the SparkleFormation library.
173
+
174
+
175
+ #### Translations
176
+
177
+ Translations are currently an `alpha` feature and only a subset of
178
+ resources are supported.
179
+
180
+ ### `knife cloudformation update STACK`
181
+
182
+ Update an existing stack.
183
+
184
+ #### Supported options
185
+
186
+ * `--print-only` print stack template JSON and exit
187
+ * `--apply-stack NAME` apply existing stack outputs
188
+ * `--[no-]processing` enable template processing
189
+ * `--file PATH` path to stack template file
190
+ * `--translate PROVIDER` translate template to provider
191
+ * `--[no-]apply-nesting` apply template nesting logic
192
+ * `--nesting-bucket BUCKET` asset store bucket to place nested stack templates
193
+
194
+ ### `knife cloudformation destroy STACK`
195
+
196
+ Destroy an existing stack.
197
+
198
+ #### Name globs
199
+
200
+ The destroy command supports globbing for performing multiple
201
+ destructions based on glob match. For example, given existing
202
+ stacks:
203
+
204
+ * TestStack1
205
+ * TestStack2
206
+ * Production
207
+
208
+ running the following command:
209
+
210
+ ```
211
+ $ knife cloudformation destroy Test*
212
+ ```
213
+
214
+ will destroy the `TestStack1` and `TestStack2`
215
+
216
+ ### `knife cloudformation events STACK`
217
+
218
+ Display the event listing of given stack. If the state of the
219
+ stack is "in progress", the polling option will result in
220
+ polling and displaying new events until the stack reaches a
221
+ completed state.
222
+
223
+ #### Supported options
224
+
225
+ * `--[no-]poll` poll for new events until completed state reached
226
+
227
+ ### `knife cloudformation describe STACK`
228
+
229
+ Display resources and outputs of give stack.
230
+
231
+ #### Supported options
232
+
233
+ * `--resources` display resources
234
+ * `--outputs` display outputs
235
+
236
+ ### `knife cloudformation inspect STACK`
237
+
238
+ The stack inspection command simply provides a proxy to the
239
+ underlying resource modeling objects provided via the
240
+ [miasma][miasma] library. It also provides extra helpers for
241
+ running common inspection commands.
242
+
243
+ ### Supported options
244
+
245
+ * `--nodes` list node addresses within stack
246
+ * `--instance-failure [LOG_FILE]` print log file from failed instance
247
+ * `--attribute ATTR` print stack attribute
248
+
249
+ #### `--nodes`
250
+
251
+ This option will return a list of compute instance IDs and
252
+ their addresses. The result will be a complete list including
253
+ direct compute resources within the stack as well as compute
254
+ resources that are part of auto scaling group resouces.
255
+
256
+ #### `--instance-failure [LOG_FILE]`
257
+
258
+ If the stack create or update failed due to a compute instance,
259
+ this option will attempt to locate the instance, connect to
260
+ it and download the defined log file. The default log file
261
+ is set to: `/var/log/chef/client.log`
262
+
263
+ #### `--attribute ATTR`
264
+
265
+ The attribute option is what provides the proxy to the underlying
266
+ [miasma][miasma] resource modeling. The value of `ATTR` is what should be
267
+ called on the `Miasma::Models::Orchestration::Stack` instance.
268
+ For example, to display the JSON template of a stack:
269
+
270
+ ```
271
+ $ knife cloudformation inspect STACK -a template
272
+ ```
273
+
274
+ To display the resource collection of the stack:
275
+
276
+ ```
277
+ $ knife cloudformation inspect STACK -a resources
278
+ ```
279
+
280
+ This will provide a list of resources. Now, to make this more
281
+ useful, we can start inspect specific resources. Lets assume
282
+ that the 3rd resource in the collection is an auto scaling
283
+ group resource. We can isolate that resource for display:
284
+
285
+ ```
286
+ $ knife cloudformation inspect STACK -a "resources.all.at(2)"
287
+ ```
288
+
289
+ Note that the resources are an array, and we are using a zero
290
+ based index. Now, this simply provides us with the information
291
+ we already have seen. One of the handy features within the
292
+ [miasma][miasma] library is the ability to expand supported resources.
293
+ So, we can expand this resource:
294
+
295
+ ```
296
+ $ knife cloudformation inspect STACK -a "resources.all.at(2).expand"
297
+ ```
298
+
299
+ This will expand the resource instance and return the actual
300
+ auto scaling group resource. The result will provide more detailed
301
+ information about the scaling group. But, perhaps we are looking
302
+ for the instances in this scaling group. The model instance we
303
+ now have (`Miasma::Orchestration::Models::AutoScale::Group`)
304
+ contains a `servers` attribute. The output lists the IDs of the
305
+ instances, but we can expand those as well:
306
+
307
+ ```
308
+ $ knife cloudformation inspect STACK -a "resources.all.at(2).expand.servers.map(&:expand)"
309
+ ```
310
+
311
+ The attribute string will be minimally processed when proxying calls
312
+ to the underlying models, which is why we are able to do ruby-ish
313
+ style things.
314
+
315
+ # Info
316
+
317
+ * Repository: https://github.com/hw-labs/knife-cloudformation
318
+ * IRC: Freenode @ #heavywater
319
+
320
+ [miasma]: http://miasma-rb.github.io/miasma/
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sfn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Roberts
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: SparkleFormation CLI
14
+ email: code@chrisroberts.org
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - README.md
20
+ homepage: http://github.com/sparkleformation/sfn
21
+ licenses:
22
+ - Apache-2.0
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: SparkleFormation CLI
44
+ test_files: []
45
+ has_rdoc: