minimal_pipeline 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e73c4e0d77f9e65390f57f1a98809904242a5e499d169157393e4d4dd83bc4d6
4
- data.tar.gz: 60b3157434d96b16a0cf34512517470fb99781547273ea98983c6efc4c16994b
3
+ metadata.gz: 80704d7d13d62a58a13a017e5f242eb80906b05b3b7157949951ea517efb5aa8
4
+ data.tar.gz: 505337f7502811f804f59161f5b3394a9304baf0b770d5ff01b487228f359425
5
5
  SHA512:
6
- metadata.gz: 46c1b528cb1f6aa3e95157ee27bd452121fb9df21c1bfef1da44f68854f225e27a9b8632cbccfb67ad2bbffc65b57228df9363d5f6f9dce470fbd1442aaf8c04
7
- data.tar.gz: 7681cab6b27244c670a0aa9aa2969f0e19a2b1cc742c5809d8f11180da24201420dc4aa9b94d991b8b0fa5ca13866be98cade614a26df5686e5f5681f6998e70
6
+ metadata.gz: 38f5fed90b82c12bc0623b15d54b0b60d860eb53dac6e9e09584abe4053250f75ada61e7c6cd1580c180ab5bc885ab2e039abbc8c1f1348ba0e2a59ed1c1cb8c
7
+ data.tar.gz: f3f2ab864e9f30c8f1634f1b602ea60c0c5a15ba3879f4a17752c8c81641057db67b269f2380c32b9f943a49b05024847c3faefc83dcd0f912c9d18a18841426
@@ -96,6 +96,42 @@ class MinimalPipeline
96
96
  stack_outputs(stack, attempt)
97
97
  end
98
98
 
99
+ def attempt_to_update_stack(stack_name, stack_parameters, wait_options,
100
+ attempt = 1)
101
+ unless @client.describe_stacks(stack_name: stack_name).stacks.empty?
102
+ puts 'Updating the existing stack' if ENV['DEBUG']
103
+ @client.update_stack(stack_parameters)
104
+ @client.wait_until(:stack_update_complete, { stack_name: stack_name },
105
+ wait_options)
106
+ end
107
+ rescue Aws::CloudFormation::Errors::Throttling => error
108
+ raise 'Unable to attempt stack update' if attempt > 5
109
+
110
+ delay = attempt * 15
111
+ puts "#{error.message} - Retrying in #{delay}"
112
+ sleep delay
113
+ attempt += 1
114
+ attempt_to_update_stack(stack_name, stack_parameters, wait_options,
115
+ attempt)
116
+ end
117
+
118
+ def attempt_to_create_stack(stack_name, stack_parameters, wait_options,
119
+ attempt = 1)
120
+ puts 'Creating a new stack' if ENV['DEBUG']
121
+ @client.create_stack(stack_parameters)
122
+ @client.wait_until(:stack_create_complete, { stack_name: stack_name },
123
+ wait_options)
124
+ rescue Aws::CloudFormation::Errors::Throttling => error
125
+ raise 'Unable to attempt stack create' if attempt > 5
126
+
127
+ delay = attempt * 15
128
+ puts "#{error.message} - Retrying in #{delay}"
129
+ sleep delay
130
+ attempt += 1
131
+ attempt_to_create_stack(stack_name, stack_parameters, wait_options,
132
+ attempt)
133
+ end
134
+
99
135
  # Creates or Updates a CloudFormation stack. Checks to see if the stack
100
136
  # already exists and takes the appropriate action. Pauses until a final
101
137
  # stack state is reached.
@@ -116,22 +152,14 @@ class MinimalPipeline
116
152
  parameters: params(parameters)
117
153
  }
118
154
 
119
- unless @client.describe_stacks(stack_name: stack_name).stacks.empty?
120
- puts 'Updating the existing stack' if ENV['DEBUG']
121
- @client.update_stack(stack_parameters)
122
- @client.wait_until(:stack_update_complete, { stack_name: stack_name },
123
- wait_options)
124
- end
155
+ attempt_to_update_stack(stack_name, stack_parameters, wait_options)
125
156
  rescue Aws::CloudFormation::Errors::ValidationError => error
126
157
  if error.to_s.include? 'No updates are to be performed.'
127
158
  puts 'Nothing to do.' if ENV['DEBUG']
128
159
  elsif error.to_s.include? 'Template error'
129
160
  raise error
130
161
  else
131
- puts 'Creating a new stack' if ENV['DEBUG']
132
- @client.create_stack(stack_parameters)
133
- @client.wait_until(:stack_create_complete, { stack_name: stack_name },
134
- wait_options)
162
+ attempt_to_create_stack(stack_name, stack_parameters, wait_options)
135
163
  end
136
164
  end
137
165
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mayowa Aladeojebi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-13 00:00:00.000000000 Z
12
+ date: 2018-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-cloudformation