cfn-status 0.4.2 → 0.4.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cfa3f286eb58e4b6178a1e5b91ae3ad1377c938e431afec5c62604ade1ae690
4
- data.tar.gz: 8726add33467c6fa4f27297579f59e1daa392ea39ebdeed2141bd457c3ea990b
3
+ metadata.gz: d783959f733a3175c56612fc8b1f9be8124f4c21fc591d87df3fc2457b57040f
4
+ data.tar.gz: c78bffbbfd322f25fa4b6c00ed8b0c98e386dac24042bfec825d409e2e4ea357
5
5
  SHA512:
6
- metadata.gz: 9e320d27a72fb9c8b644443ae7774ea3c8d0c8862905a2ac75b405fc02e82c2d02c801c78b5602ce311bb8706ffc436f34a98fcdc7f445dc31c57edfc8649134
7
- data.tar.gz: 25feec8075d4575ddec75f57531790a634b57e1bfce690e61cb24882505d390051a53f4304b19a0d7eb0096a975284c29aefa17bae41d62632e569de30ec9e5b
6
+ metadata.gz: a2a89727d0321574dda3f212dbdfeff7ffae32ae3621de889191f6632d8b1aae8c98dd5f8b16c32c80789864fe0d63665fca304831c07e2bc015c5db310e6c34
7
+ data.tar.gz: e691c6788d1a5400d80e4e2ff01157dd80985f0464c58118cf78e04364bf055f24784cc662d93f72237d415f497c0d0eb1ec0b7a3c24872f903fec4eff5c6e43
data/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely* adheres to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.4.6] - 2022-02-21
7
+ - show took time for deletion also
8
+
9
+ ## [0.4.5] - 2022-02-20
10
+ - [#5](https://github.com/tongueroo/cfn-status/pull/5) cfn-status retry options
11
+
12
+ ## [0.4.4] - 2022-02-14
13
+ - more generic time took message
14
+
15
+ ## [0.4.3] - 2021-05-27
16
+ - [#4](https://github.com/tongueroo/cfn-status/pull/4) fix current status message
17
+
6
18
  ## [0.4.2]
7
19
  - #3 improve messaging when wait called directly. dont show old events.
8
20
 
@@ -3,7 +3,7 @@ require "aws-sdk-cloudformation"
3
3
  class CfnStatus
4
4
  module AwsService
5
5
  def cfn
6
- @cfn ||= Aws::CloudFormation::Client.new
6
+ @cfn ||= Aws::CloudFormation::Client.new(aws_options)
7
7
  end
8
8
 
9
9
  def stack_exists?(stack_name)
@@ -47,5 +47,36 @@ class CfnStatus
47
47
  def rollback_complete?(stack)
48
48
  stack&.stack_status == 'ROLLBACK_COMPLETE'
49
49
  end
50
+
51
+ # Override the AWS retry settings.
52
+ #
53
+ # The aws-sdk-core has exponential backup with this formula:
54
+ #
55
+ # 2 ** c.retries * c.config.retry_base_delay
56
+ #
57
+ # Source:
58
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
59
+ #
60
+ # So the max delay will be 2 ** 7 * 0.6 = 76.8s
61
+ #
62
+ # Only scoping this to deploy because dont want to affect people's application that use the aws sdk.
63
+ #
64
+ # There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.
65
+ #
66
+ # Useful links:
67
+ # https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
68
+ # https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
69
+ #
70
+ def aws_options
71
+ options = {
72
+ retry_limit: 7, # default: 3
73
+ retry_base_delay: 0.6, # default: 0.3
74
+ }
75
+ options.merge!(
76
+ log_level: :debug,
77
+ logger: Logger.new($stdout),
78
+ ) if ENV['CFN_STATUS_DEBUG_AWS_SDK']
79
+ options
80
+ end
50
81
  end
51
82
  end
@@ -1,3 +1,3 @@
1
1
  class CfnStatus
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.6"
3
3
  end
data/lib/cfn_status.rb CHANGED
@@ -7,11 +7,13 @@ class CfnStatus
7
7
  autoload :AwsService, "cfn_status/aws_service"
8
8
  include AwsService
9
9
 
10
- attr_reader :events
10
+ attr_reader :events, :stack
11
11
  def initialize(stack_name, options={})
12
12
  @stack_name = stack_name
13
13
  @options = options
14
14
  @cfn = options[:cfn] # allow use of different cfn client. can be useful multiple cfn clients and with different regions
15
+ resp = cfn.describe_stacks(stack_name: @stack_name)
16
+ @stack = resp.stacks.first
15
17
  reset
16
18
  end
17
19
 
@@ -37,8 +39,6 @@ class CfnStatus
37
39
  end
38
40
 
39
41
  def in_progress?
40
- resp = cfn.describe_stacks(stack_name: @stack_name)
41
- stack = resp.stacks.first
42
42
  in_progress = stack.stack_status =~ /_IN_PROGRESS$/
43
43
  !!in_progress
44
44
  end
@@ -66,6 +66,7 @@ class CfnStatus
66
66
 
67
67
  if @stack_deletion_completed
68
68
  puts "Stack #{@stack_name} deleted."
69
+ show_took(start_time)
69
70
  return
70
71
  end
71
72
 
@@ -82,11 +83,15 @@ class CfnStatus
82
83
  end
83
84
 
84
85
  return if @hide_time_took # set in run
85
- took = Time.now - start_time
86
- puts "Time took for stack deployment: #{pretty_time(took).color(:green)}."
86
+ show_took(start_time)
87
87
  success?
88
88
  end
89
89
 
90
+ def show_took(start_time)
91
+ took = Time.now - start_time
92
+ puts "Time took: #{pretty_time(took).color(:green)}"
93
+ end
94
+
90
95
  def completed
91
96
  last_event_status =~ /(_COMPLETE|_FAILED)$/ &&
92
97
  @events[0]["logical_resource_id"] == @stack_name &&
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfn-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-24 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudformation
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.1.2
111
+ rubygems_version: 3.2.32
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: CloudFormation status library