cfer 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/cfer.rb +22 -5
- data/lib/cfer/cfn/client.rb +2 -0
- data/lib/cfer/cli.rb +9 -2
- data/lib/cfer/core/stack.rb +5 -1
- data/lib/cfer/util/json.rb +82 -0
- data/lib/cfer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f1a58671c07486f353aa90896557273e4d3e241
|
4
|
+
data.tar.gz: da2c6b400309256e52e037fb779e7ad9ffbec7ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dd4d902637c52dff7d817408bc31ff0a6369e9ff7d9f6698622007fd732d5b550b7c7b5ebee18998925660964caeceed18722cee2c4f7587c260c08a6a98c53
|
7
|
+
data.tar.gz: b60810b50244a46dbf5e81c67be25e67b6ee41cda5f08f225a8d570b5575d01c65ae390ec9fb4bc61a065c0e73123aabe0fcbf7946def8159534ffd3b83f72f7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Cfer Change Log
|
2
2
|
|
3
|
+
## 0.6.0
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
* Colorized JSON in `generate` for more readable output. #41
|
7
|
+
* Adds `--notification-arns` CLI option. #43
|
8
|
+
* Adds `--role-arn` CLI option. #46
|
9
|
+
|
10
|
+
### Bugfixes
|
11
|
+
* Don't dump backtrace when trying to delete a nonexistent stack. #42
|
12
|
+
|
3
13
|
## 0.5.0
|
4
14
|
|
5
15
|
### **BREAKING CHANGES**
|
data/lib/cfer.rb
CHANGED
@@ -85,11 +85,17 @@ module Cfer
|
|
85
85
|
when 'Continue'
|
86
86
|
retry
|
87
87
|
when 'Rollback'
|
88
|
+
rollback_opts = {
|
89
|
+
stack_name: stack_name
|
90
|
+
}
|
91
|
+
|
92
|
+
rollback_opts[:role_arn] = options[:role_arn] if options[:role_arn]
|
93
|
+
|
88
94
|
case operation
|
89
95
|
when :created
|
90
|
-
cfn_stack.delete_stack
|
96
|
+
cfn_stack.delete_stack rollback_opts
|
91
97
|
when :updated
|
92
|
-
cfn_stack.cancel_update_stack
|
98
|
+
cfn_stack.cancel_update_stack rollback_opts
|
93
99
|
end
|
94
100
|
retry
|
95
101
|
end
|
@@ -185,11 +191,22 @@ module Cfer
|
|
185
191
|
config(options)
|
186
192
|
cfn = options[:aws_options] || {}
|
187
193
|
cfn_stack = options[:cfer_client] || cfn_stack = Cfer::Cfn::Client.new(cfn.merge(stack_name: stack_name))
|
188
|
-
|
194
|
+
|
195
|
+
delete_opts = {
|
196
|
+
stack_name: stack_name
|
197
|
+
}
|
198
|
+
delete_opts[:role_arn] = options[:role_arn] if options[:role_arn]
|
199
|
+
cfn_stack.delete_stack(delete_opts)
|
189
200
|
|
190
201
|
if options[:follow]
|
191
202
|
tail! stack_name, options.merge(cfer_client: cfn_stack)
|
192
203
|
end
|
204
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
205
|
+
if e.message =~ /Stack .* does not exist/
|
206
|
+
raise Cfer::Util::StackDoesNotExistError, e.message
|
207
|
+
else
|
208
|
+
raise e
|
209
|
+
end
|
193
210
|
end
|
194
211
|
|
195
212
|
# Builds a Cfer::Core::Stack from a Ruby block
|
@@ -270,7 +287,7 @@ module Cfer
|
|
270
287
|
|
271
288
|
def render_json(obj, options = {})
|
272
289
|
if options[:pretty_print]
|
273
|
-
puts
|
290
|
+
puts Cfer::Util::Json.format_json(obj)
|
274
291
|
else
|
275
292
|
puts obj.to_json
|
276
293
|
end
|
@@ -336,6 +353,7 @@ block.rb
|
|
336
353
|
config.rb
|
337
354
|
|
338
355
|
util/error.rb
|
356
|
+
util/json.rb
|
339
357
|
|
340
358
|
core/hooks.rb
|
341
359
|
core/client.rb
|
@@ -349,4 +367,3 @@ cfn/client.rb
|
|
349
367
|
require "#{File.dirname(__FILE__)}/cfer/#{f}"
|
350
368
|
end
|
351
369
|
Dir["#{File.dirname(__FILE__)}/cferext/**/*.rb"].each { |f| require(f) }
|
352
|
-
|
data/lib/cfer/cfn/client.rb
CHANGED
@@ -119,6 +119,8 @@ module Cfer::Cfn
|
|
119
119
|
|
120
120
|
stack_options[:on_failure] = options[:on_failure] if options[:on_failure]
|
121
121
|
stack_options[:timeout_in_minutes] = options[:timeout] if options[:timeout]
|
122
|
+
stack_options[:role_arn] = options[:role_arn] if options[:role_arn]
|
123
|
+
stack_options[:notification_arns] = options[:notification_arns] if options[:notification_arns]
|
122
124
|
|
123
125
|
stack_options.merge! parse_stack_policy(:stack_policy, options[:stack_policy])
|
124
126
|
|
data/lib/cfer/cli.rb
CHANGED
@@ -39,9 +39,14 @@ module Cfer
|
|
39
39
|
optional nil, 'on-failure', 'The action to take if the stack creation fails'
|
40
40
|
optional nil, 'timeout', 'The timeout (in minutes) before the stack operation aborts'
|
41
41
|
#flag nil, 'git-lock', 'When enabled, Cfer will not converge a stack in a dirty git tree'
|
42
|
+
optional nil,
|
43
|
+
'notification-arns',
|
44
|
+
'SNS topic ARN to publish stack related events. This option can be supplied multiple times.',
|
45
|
+
multiple: true
|
42
46
|
|
43
47
|
optional :s, 'stack-policy', 'Set a new stack policy on create or update of the stack [file|url|json]'
|
44
48
|
optional :u, 'stack-policy-during-update', 'Set a temporary overriding stack policy during an update [file|url|json]'
|
49
|
+
optional nil, 'role-arn', 'Pass a specific role ARN for CloudFormation to use (--role-arn in AWS CLI)'
|
45
50
|
|
46
51
|
optional nil, 'change', 'Issues updates as a Cfn change set.'
|
47
52
|
optional nil, 'change-description', 'The description of this Cfn change'
|
@@ -128,6 +133,8 @@ module Cfer
|
|
128
133
|
usage 'delete <stack>'
|
129
134
|
summary 'Deletes a CloudFormation stack'
|
130
135
|
|
136
|
+
optional nil, 'role-arn', 'Pass a specific role ARN for CloudFormation to use (--role-arn in AWS CLI)'
|
137
|
+
|
131
138
|
run do |options, args, cmd|
|
132
139
|
Cfer::Cli.fixup_options(options)
|
133
140
|
options[:number] = 0
|
@@ -156,10 +163,10 @@ module Cfer
|
|
156
163
|
Cfer::LOGGER.fatal "Template error: #{e.message}"
|
157
164
|
Cfer::LOGGER.fatal Cfer::Cli.format_backtrace(e.template_backtrace) unless e.template_backtrace.empty?
|
158
165
|
exit 1
|
159
|
-
rescue Cfer::Util::CferError => e
|
166
|
+
rescue Cfer::Util::CferError, Cfer::Util::StackDoesNotExistError => e
|
160
167
|
Cfer::LOGGER.error "#{e.message}"
|
161
168
|
exit 1
|
162
|
-
rescue
|
169
|
+
rescue StandardError => e
|
163
170
|
Cfer::LOGGER.fatal "#{e.class.name}: #{e.message}"
|
164
171
|
Cfer::LOGGER.fatal Cfer::Cli.format_backtrace(e.backtrace) unless e.backtrace.empty?
|
165
172
|
|
data/lib/cfer/core/stack.rb
CHANGED
@@ -155,7 +155,11 @@ module Cfer::Core
|
|
155
155
|
# Renders the stack into a CloudFormation template.
|
156
156
|
# @return [String] The final template
|
157
157
|
def to_cfn
|
158
|
-
|
158
|
+
if @options[:pretty_print]
|
159
|
+
JSON.pretty_generate(to_h)
|
160
|
+
else
|
161
|
+
to_h.to_json
|
162
|
+
end
|
159
163
|
end
|
160
164
|
|
161
165
|
# Gets the Cfn client, if one exists, or throws an error if one does not
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Cfer::Util::Json
|
5
|
+
class << self
|
6
|
+
|
7
|
+
QUOTE = '"'
|
8
|
+
LBRACE = Rainbow('{').green
|
9
|
+
RBRACE = Rainbow('}').green
|
10
|
+
LBRACKET = Rainbow('[').green
|
11
|
+
RBRACKET = Rainbow(']').green
|
12
|
+
COLON = Rainbow(': ').green
|
13
|
+
|
14
|
+
def format_json(item)
|
15
|
+
case item
|
16
|
+
when Hash
|
17
|
+
format_hash(item)
|
18
|
+
when Array
|
19
|
+
format_array(item)
|
20
|
+
when String
|
21
|
+
format_string(item)
|
22
|
+
when Numeric
|
23
|
+
format_number(item)
|
24
|
+
when TrueClass || FalseClass
|
25
|
+
format_bool(item)
|
26
|
+
else
|
27
|
+
format_string(item.to_s)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def format_string(s)
|
33
|
+
s.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def format_number(n)
|
37
|
+
n.to_json
|
38
|
+
end
|
39
|
+
|
40
|
+
def format_bool(b)
|
41
|
+
b.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
def format_hash(h)
|
45
|
+
LBRACE +
|
46
|
+
if h.empty?
|
47
|
+
' '
|
48
|
+
else
|
49
|
+
"\n" +
|
50
|
+
indent do
|
51
|
+
h.map { |k, v| format_pair(k, v) }.join(",\n")
|
52
|
+
end +
|
53
|
+
"\n"
|
54
|
+
end +
|
55
|
+
RBRACE
|
56
|
+
end
|
57
|
+
|
58
|
+
def format_pair(k, v)
|
59
|
+
QUOTE + Rainbow(k).bright + QUOTE + COLON + format_json(v)
|
60
|
+
end
|
61
|
+
|
62
|
+
def format_array(a)
|
63
|
+
LBRACKET +
|
64
|
+
if a.empty?
|
65
|
+
' '
|
66
|
+
else
|
67
|
+
"\n" +
|
68
|
+
indent do
|
69
|
+
a.map { |i| format_json(i) }.join(",\n")
|
70
|
+
end +
|
71
|
+
"\n"
|
72
|
+
end +
|
73
|
+
RBRACKET
|
74
|
+
end
|
75
|
+
|
76
|
+
def indent
|
77
|
+
str = yield
|
78
|
+
" " + str.gsub(/\n/, "\n ")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
data/lib/cfer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Edwards
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- lib/cfer/core/resource.rb
|
239
239
|
- lib/cfer/core/stack.rb
|
240
240
|
- lib/cfer/util/error.rb
|
241
|
+
- lib/cfer/util/json.rb
|
241
242
|
- lib/cfer/version.rb
|
242
243
|
- lib/cferext/aws/auto_scaling/auto_scaling_group.rb
|
243
244
|
- lib/cferext/aws/cloud_formation/wait_condition.rb
|