Class: CfnCli::Cli
Defined Under Namespace
Modules: ExitCode
Instance Method Summary
collapse
Methods included from Loggable
#log_level, #log_level=, #logger, #logger=
#options
Instance Method Details
#apply ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/cfncli/cli.rb', line 139
def apply
opts = process_params(options)
stack_name = opts['stack_name']
fail ArgumentError, 'stack_name is required' unless stack_name
timeout = consume_option(opts, 'timeout')
interval = consume_option(opts, 'interval')
retries = timeout / interval
fail_on_noop = consume_option(opts, 'fail_on_noop')
list_events = consume_option(opts, 'list_events')
retry_limit = consume_option(opts, 'retry_limit')
config_file = consume_option(opts, 'config_file')
ENV['CFNCLI_LOG_LEVEL'] = consume_option(opts, 'log_level').to_s
logger.debug "Apply parameters: #{options.inspect}"
client_config = Config::CfnClient.new(interval, retries, fail_on_noop, retry_limit)
res = ExitCode::OK
if list_events
cfn.apply_and_list_events(opts, client_config)
res = ExitCode::STACK_ERROR unless cfn.stack_successful? stack_name
else
cfn.create_stack(opts, client_config)
end
puts "Stack #{stack_name} creation #{res == 0 ? 'successful' : 'failed'}"
exit res
rescue Aws::CloudFormation::Errors::ValidationError => e
puts e.message
exit ExitCode::VALIDATION_ERROR
end
|
#create ⇒ Object
7
8
9
|
# File 'lib/cfncli.rb', line 7
def create
puts "Creating stack"
end
|
#delete ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
# File 'lib/cfncli/cli.rb', line 243
def delete
opts = options.dup
stack_name = opts['stack_name']
fail ArgumentError, 'stack_name is required' unless stack_name
list_events = consume_option(opts, 'list_events')
interval = consume_option(opts, 'interval')
timeout = consume_option(opts, 'timeout')
retry_limit = consume_option(opts, 'timeout')
consume_option(opts, 'log_level')
consume_option(opts, 'config_file')
retries = timeout / interval
client_config = Config::CfnClient.new(interval, retries, retry_limit)
if list_events
stack = cfn.delete_and_list_events(opts, client_config)
res = ExitCode::STACK_ERROR unless cfn.stack_successful? stack.stack_id
else
cfn.delete_stack(opts, client_config)
end
end
|
#events ⇒ Object
201
202
203
204
205
206
207
208
|
# File 'lib/cfncli/cli.rb', line 201
def events
stack_name = options['stack_name']
fail ArgumentError, 'stack_name is required' unless stack_name
config = Config::CfnClient.new(options['interval'], options['retries'], options['retry_limit'])
cfn.events(stack_name, config, options['list_nested_events'])
end
|
#version ⇒ Object
273
274
275
276
277
|
# File 'lib/cfncli/cli.rb', line 273
def version
program_name = $PROGRAM_NAME
program_name = File.basename program_name unless options['verbose']
puts "#{program_name} v#{CfnCli::VERSION}"
end
|