cfn-status 0.4.1 → 0.4.5

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: 7b5779a34350074951fd6e52df7e72dbd1d78a291bcd394ab04ef4e85101d4c2
4
- data.tar.gz: 104e5f8f7665e2f42c26c8f60d65ac2027022c883f622134abb815b59195c955
3
+ metadata.gz: 7b8d3f2b5eaaab5d41d434b53fdb4ed16337bac065772db5efd0da6869f03d7c
4
+ data.tar.gz: 7412b786f0ab988f2c20100222026a13fa8cd1385742efc2cc074d6bfb319925
5
5
  SHA512:
6
- metadata.gz: 76c29de282df67688889e29cec71240ae37fdbbd19cc581067761b0c8d73757f76929db1bc5900eee52cd844b72e5b44a1b4566d1584a2a802ed98bd9ca81151
7
- data.tar.gz: 65e8894d61f52ae4fd19ee1801301fbc8934f6cab0cd7c875b586693dda423a33b3f2447fa9813675fbc17511f544f78c73166f0655293b90a259056521e5f7a
6
+ metadata.gz: 1b32d13db397770b601204ec8c9dcc33d28c0f7671863d84a8e3e225adfd2feb5674eba8ff06e808cb8399f5452e3fb9b3d9f267cc4b90288da0e02c16ea5604
7
+ data.tar.gz: 97dfb7f30531b3269c255af4d892e4c67084cc6c21670adc43efa48c5927088317983fdfe00888ee29a5a3395fbfb3c162c632aba34470aa67b7b1056875b6aa
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.5] - 2022-02-20
7
+ - [#5](https://github.com/tongueroo/cfn-status/pull/5) cfn-status retry options
8
+
9
+ ## [0.4.4] - 2022-02-14
10
+ - more generic time took message
11
+
12
+ ## [0.4.3] - 2021-05-27
13
+ - [#4](https://github.com/tongueroo/cfn-status/pull/4) fix current status message
14
+
15
+ ## [0.4.2]
16
+ - #3 improve messaging when wait called directly. dont show old events.
17
+
6
18
  ## [0.4.1]
7
19
  - fix require cfn_status/rollback_stack
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.1"
2
+ VERSION = "0.4.5"
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
 
@@ -21,11 +23,8 @@ class CfnStatus
21
23
  return true
22
24
  end
23
25
 
24
- resp = cfn.describe_stacks(stack_name: @stack_name)
25
- stack = resp.stacks.first
26
-
27
26
  puts "The current status for the stack #{@stack_name.color(:green)} is #{stack.stack_status.color(:green)}"
28
- if stack.stack_status =~ /_IN_PROGRESS$/
27
+ if in_progress?
29
28
  puts "Stack events (tailing):"
30
29
  # tail all events until done
31
30
  @hide_time_took = true
@@ -39,6 +38,11 @@ class CfnStatus
39
38
  success?
40
39
  end
41
40
 
41
+ def in_progress?
42
+ in_progress = stack.stack_status =~ /_IN_PROGRESS$/
43
+ !!in_progress
44
+ end
45
+
42
46
  def reset
43
47
  @events = [] # constantly replaced with recent events
44
48
  @last_shown_event_id = nil
@@ -47,6 +51,10 @@ class CfnStatus
47
51
 
48
52
  # check for /(_COMPLETE|_FAILED)$/ status
49
53
  def wait
54
+ # Check for in progress again in case .wait is called from other libraries like s3-antivirus
55
+ # Showing the event messages when will show old messages which can be confusing.
56
+ return unless in_progress?
57
+
50
58
  puts "Waiting for stack to complete"
51
59
  start_time = Time.now
52
60
 
@@ -75,7 +83,7 @@ class CfnStatus
75
83
 
76
84
  return if @hide_time_took # set in run
77
85
  took = Time.now - start_time
78
- puts "Time took for stack deployment: #{pretty_time(took).color(:green)}."
86
+ puts "Time took: #{pretty_time(took).color(:green)}."
79
87
  success?
80
88
  end
81
89
 
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.1
4
+ version: 0.4.5
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-23 00:00:00.000000000 Z
11
+ date: 2022-02-20 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