cfncli 0.4.0 → 0.5.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjNiNjlmM2JmYzE1YTY1MWE5MjYyNjQ4MDcwZWNkNDFjNzM0MGVjNA==
4
+ OTM5YTRjNGYyYjhmZjc5YWI2ZTc3NWFhYzliMjIzZTMyMjE0ZDM5Nw==
5
5
  data.tar.gz: !binary |-
6
- MzVhNzQ1MzExYjZjOTJlNTgyZjczZDliMTUxZjdjOTQyMTVhYzY2ZA==
6
+ Yzk3ZmMxOGQzMzA0M2IyZWU4NmI2NzFiNDc0NzgwMTEyZDllYmI5Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjRlZDA3YzA3MmY5ZWUyOGE5ZTRhNjQ3YWNlNTBiNmE0Y2E4MTFiMTc1ZWM4
10
- Y2VhZGQ5ZDdlYjU4YjJjYjBlMTlhZmNkZmNkOWJhYTMyMzc2N2Y2YTdlYjg1
11
- NGI5NGRjYjljOGJmMmJiZjkxYTZlNWNkZmYxOGEwZTQyZmQxNjI=
9
+ ZjdjMzAzYTIyZWI5Zjk2MWE0MTgzY2RmMThkMmViOWU3MjE0ZGQxMTU5YWJh
10
+ ODQzYmQxMGQ3OWIzZjc0ZGU0NDc4YTc5OTRkNWExOWIxYjkzMmVkOGU2NWZi
11
+ ODBmNTc1N2VmMDU1MmFlMDUxZTUwOWVjMzdiMWEzNjQ2ZGViN2M=
12
12
  data.tar.gz: !binary |-
13
- ODRkMGE3ZGI5NGY4MWI1NGJkYTllN2IwMmFmMjNkYWZiZTUwYTQ2ZGIxMDFh
14
- OTAzZmE5NzEzMDM1MGQxMTViZDYxZjBjNDM0OTQ1NTNiM2QwN2E1NjYzNzI0
15
- MWE1MWVkZjEyZTcyNjAwYTkxOGIwOGY1NzRlYjYxZjNlNjAzMTI=
13
+ ZTI2MGYyNWExNTljMmI4ZjRlMTZhMWI4MDdiNzNhZGNmODgwMmEyZjViZjkw
14
+ OWNiZjRkOGQwYzdjNjg1N2ZhYzgyZTI1YTYxY2RkMGI2OTBmYjBhY2RiYzll
15
+ NzE3ODJlYzNkODNhZGIyODZiZmMzZjI3NWNiZWI1MDA5MjQ3NGI=
@@ -4,11 +4,17 @@ module CfnCli
4
4
  module CfnClient
5
5
 
6
6
  attr_accessor :stub_responses
7
+ attr_accessor :retry_limit
8
+ attr_accessor :retry_backoff
7
9
 
8
10
  # CloudFormation client
9
11
  # @see http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html
10
12
  def cfn_client
11
- @@client ||= Aws::CloudFormation::Client.new(stub_responses: stub_responses || false)
13
+ options ||= {}
14
+ options[:retry_limit] = @retry_limit if @retry_limit
15
+ options[:retry_backoff] = @retry_backoff if @retry_backoff
16
+ options[:stub_responses] = @stub_responses || false
17
+ @@client ||= Aws::CloudFormation::Client.new(**options)
12
18
  end
13
19
 
14
20
  # Clouformation Resource
@@ -23,7 +23,7 @@ module CfnCli
23
23
  type: :numeric,
24
24
  default: 1,
25
25
  desc: 'Log level to display (0=DEBUG, 1=INFO, 2=ERROR, 3=CRITICAL)'
26
-
26
+
27
27
  class_option 'config_file',
28
28
  type: :string,
29
29
  default: 'cfncli.yml',
@@ -56,7 +56,6 @@ module CfnCli
56
56
 
57
57
  method_option 'disable_rollback',
58
58
  type: :boolean,
59
- default: false,
60
59
  desc: 'Disable rollbacks in case of a stack update failure'\
61
60
  ' This is mutually exclusive with on_failure.'
62
61
 
@@ -81,7 +80,7 @@ module CfnCli
81
80
 
82
81
  method_option 'stack_policy_body',
83
82
  type: :string,
84
- desc: 'JSON String containing the stack policy body. The @filename syntax can be used.'
83
+ desc: 'JSON String containing the stack policy body. The @filename syntax can be used.'
85
84
 
86
85
  method_option 'stack_policy_url',
87
86
  type: :string,
@@ -114,35 +113,41 @@ module CfnCli
114
113
  default: false,
115
114
  desc: 'Fails if a stack has nothing to update'
116
115
 
116
+ method_option 'retry_limit',
117
+ type: :numeric,
118
+ default: 5,
119
+ desc: 'Maximum number of retries for the AWS backoff mechanism'
120
+
117
121
  desc 'apply', 'Creates a stack in Cloudformation'
118
122
  def apply
119
123
  opts = process_params(options)
120
124
 
121
125
  stack_name = opts['stack_name']
122
126
  fail ArgumentError, 'stack_name is required' unless stack_name
123
-
127
+
124
128
  timeout = consume_option(opts, 'timeout')
125
129
  interval = consume_option(opts, 'interval')
126
130
  retries = timeout / interval
127
131
  fail_on_noop = consume_option(opts, 'fail_on_noop')
128
132
  list_events = consume_option(opts, 'list_events')
133
+ retry_limit = consume_option(opts, 'retry_limit')
129
134
  config_file = consume_option(opts, 'config_file')
130
135
 
131
136
  ENV['CFNCLI_LOG_LEVEL'] = consume_option(opts, 'log_level').to_s
132
137
 
133
138
  logger.debug "Apply parameters: #{options.inspect}"
134
139
 
135
- client_config = Config::CfnClient.new(interval, retries, fail_on_noop)
140
+ client_config = Config::CfnClient.new(interval, retries, fail_on_noop, retry_limit)
136
141
 
137
- res = ExitCode::OK
142
+ res = ExitCode::OK
138
143
  if list_events
139
- cfn.apply_and_list_events(opts, client_config)
144
+ cfn.apply_and_list_events(opts, client_config)
140
145
  res = ExitCode::STACK_ERROR unless cfn.stack_successful? stack_name
141
146
  else
142
147
  cfn.create_stack(opts, client_config)
143
148
  end
144
149
 
145
- puts "Stack creation #{res == 0 ? 'successful' : 'failed'}"
150
+ puts "Stack #{stack_name} creation #{res == 0 ? 'successful' : 'failed'}"
146
151
  exit res
147
152
  rescue Aws::CloudFormation::Errors::ValidationError => e
148
153
  puts e.message
@@ -168,13 +173,13 @@ module CfnCli
168
173
  desc 'events', 'Displays the events for a stack in realtime'
169
174
  def events
170
175
  stack_name = options['stack_name']
171
-
176
+
172
177
  fail ArgumentError, 'stack_name is required' unless stack_name
173
-
178
+
174
179
  config = Config::CfnClient.new(options['interval'], options['retries'])
175
180
  cfn.events(stack_name, config)
176
181
  end
177
-
182
+
178
183
  method_option 'stack_name',
179
184
  aliases: ['-n'],
180
185
  type: :string,
@@ -195,9 +200,9 @@ module CfnCli
195
200
  def delete
196
201
  opts = options.dup
197
202
  stack_name = opts['stack_name']
198
-
203
+
199
204
  fail ArgumentError, 'stack_name is required' unless stack_name
200
-
205
+
201
206
  interval = consume_option(opts, 'interval')
202
207
  timeout = consume_option(opts, 'timeout')
203
208
  consume_option(opts, 'log_level')
@@ -279,7 +284,7 @@ module CfnCli
279
284
 
280
285
  # Converts a parameter JSON file to the format expected by CloudFormation
281
286
  # @param filename Path to the JSON file containing the parameters description
282
- # @return
287
+ # @return
283
288
  def process_stack_parameters_file(filename)
284
289
  content = File.read(filename)
285
290
  return CloudFormation.parse_json_params(JSON.parse(content))
@@ -8,16 +8,20 @@ module CfnCli
8
8
  rescue Errno::ENOENT
9
9
  nil
10
10
  end
11
-
11
+
12
12
  class CfnClient
13
13
  attr_accessor :interval
14
14
  attr_accessor :retries
15
15
  attr_accessor :fail_on_noop
16
-
17
- def initialize(interval = 10, retries = 30, fail_on_noop = false)
16
+ attr_accessor :aws_retry_limit
17
+ attr_accessor :aws_retry_backoff
18
+
19
+ def initialize(interval = 10, retries = 30, fail_on_noop = false, aws_retry_limit = 5, aws_retry_backoff = nil)
18
20
  @interval = interval
19
21
  @retries = retries
20
22
  @fail_on_noop = fail_on_noop
23
+ @aws_retry_limit = aws_retry_limit
24
+ @aws_retry_backoff = aws_retry_backoff
21
25
  end
22
26
  end
23
27
  end
@@ -25,6 +25,9 @@ module CfnCli
25
25
  @stack_name = stack_name
26
26
  @config = config || default_config
27
27
  @child_stacks = Concurrent::Array.new
28
+
29
+ @retry_limit = @config.aws_retry_limit
30
+ @retry_backoff = @config.aws_retry_backoff
28
31
  end
29
32
 
30
33
  def default_config
@@ -1,3 +1,3 @@
1
1
  module CfnCli
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfncli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lethalpaga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler