stackup 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/README.md +10 -11
- data/bin/stackup +1 -0
- data/lib/stackup/change_set.rb +23 -17
- data/lib/stackup/differ.rb +2 -0
- data/lib/stackup/error_handling.rb +2 -0
- data/lib/stackup/errors.rb +2 -0
- data/lib/stackup/main_command.rb +4 -14
- data/lib/stackup/parameters.rb +8 -6
- data/lib/stackup/rake_tasks.rb +3 -2
- data/lib/stackup/service.rb +2 -0
- data/lib/stackup/source.rb +2 -0
- data/lib/stackup/stack_watcher.rb +4 -4
- data/lib/stackup/utils.rb +2 -0
- data/lib/stackup/version.rb +3 -1
- data/lib/stackup/yaml.rb +2 -0
- data/lib/stackup.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/stackup/main_command_spec.rb +19 -14
- data/spec/stackup/parameters_spec.rb +2 -0
- data/spec/stackup/rake_tasks_spec.rb +2 -0
- data/spec/stackup/source_spec.rb +2 -0
- data/spec/stackup/stack_spec.rb +11 -9
- data/spec/stackup/stack_watcher_spec.rb +2 -0
- data/spec/stackup/utils_spec.rb +2 -0
- data/spec/stackup/yaml_spec.rb +2 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f74cb61004ec9220d92f5f1d1ff292607b216233bc5aed7668d31027e4e2d2b3
|
4
|
+
data.tar.gz: 18cce0dfddda4b0870affec164d0d0c9cdb30e2e25f1ea675e3b64bd3385323e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a0621de917ddd7bc2163756c854ad89bae2f79e5b8f1d784e04042b55f4a5a9ea5a84bed89f305c4604efc7c9ccb01ec46c32ec3635e3d03f3148b5b3db0ed
|
7
|
+
data.tar.gz: ac2b19120472ed87471053394d1383d860939a562aebdf5e17fa2a3fc1290b48397c1dae1d9b6c752d6a0a4fd041716b9c753be42f135661303863e2e471397d
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# stackup
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/stackup.png)](http://badge.fury.io/rb/stackup)
|
4
|
-
[![Build Status](https://travis-ci.
|
4
|
+
[![Build Status](https://travis-ci.com/realestate-com-au/stackup.svg?branch=main)](https://travis-ci.com/realestate-com-au/stackup)
|
5
5
|
|
6
6
|
Stackup provides a CLI and a simplified Ruby API for dealing with
|
7
7
|
AWS CloudFormation stacks.
|
@@ -191,7 +191,7 @@ Where a template URL references an object in S3, `stackup` leverages [CloudForma
|
|
191
191
|
Non-S3 URLs are also supported, though in that case `stackup` must fetch the content itself:
|
192
192
|
|
193
193
|
$ stackup mystack up \
|
194
|
-
-t https://raw.githubusercontent.com/realestate-com-au/stackup/
|
194
|
+
-t https://raw.githubusercontent.com/realestate-com-au/stackup/main/examples/template.yml
|
195
195
|
|
196
196
|
### Stack deletion
|
197
197
|
|
@@ -309,19 +309,18 @@ This policy grants the principal all actions required by `stackup up` for any cl
|
|
309
309
|
### Running tests
|
310
310
|
|
311
311
|
`auto/test` will run the tests in a Docker container.
|
312
|
+
`auto/lint` will run the linter in a Docker container.
|
312
313
|
|
313
314
|
### Releasing
|
314
315
|
|
315
|
-
Releasing is done
|
316
|
+
Releasing is done mostly by CI. The automated process will push tags to GitHub, push the docker images to DockerHub. It won't yet push the gem to `rubygems.org`, but we're working ok it..
|
316
317
|
|
317
318
|
Prerequisites:
|
318
319
|
|
319
|
-
* You must
|
320
|
-
* You
|
321
|
-
* You
|
320
|
+
* You must have a rubygems account with permission to push to the `stackup` gem. (`auto/release-gem` will ask for your username and password)
|
321
|
+
* You have bumped the version number in `lib/stackup/version.rb`.
|
322
|
+
* You have checked the `CHANGES.md` file to make sure it is reasonable and has the changes for this new version.
|
322
323
|
|
323
|
-
To release
|
324
|
-
|
325
|
-
|
326
|
-
auto/release
|
327
|
-
```
|
324
|
+
To release the rubygem.
|
325
|
+
1. `auto/release-gem`
|
326
|
+
2. On REA's internal CI tool of choice, find the build for `stackup-ci` and trigger a new build from `HEAD`. This will always grab the latest code from here and release the rest of the parts.
|
data/bin/stackup
CHANGED
data/lib/stackup/change_set.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "stackup/error_handling"
|
2
4
|
|
3
5
|
module Stackup
|
@@ -51,20 +53,9 @@ module Stackup
|
|
51
53
|
# @raise [Stackup::NoSuchStack] if the stack doesn't exist
|
52
54
|
#
|
53
55
|
def create(options = {})
|
54
|
-
options = options
|
55
|
-
|
56
|
-
options[:change_set_name] = name
|
57
|
-
options[:change_set_type] = stack.exists? ? "UPDATE" : "CREATE"
|
58
|
-
force = options.delete(:force)
|
56
|
+
options = validate_options(options)
|
57
|
+
delete if options.delete(:force)
|
59
58
|
allow_empty_change_set = options.delete(:allow_empty_change_set)
|
60
|
-
options[:template_body] = MultiJson.dump(options.delete(:template)) if options[:template]
|
61
|
-
# optionally override template_body with the original template to preserve formatting (& comments in YAML)
|
62
|
-
template_orig = options.delete(:template_orig)
|
63
|
-
options[:template_body] = template_orig if options.delete(:preserve)
|
64
|
-
options[:parameters] = Parameters.new(options[:parameters]).to_a if options[:parameters]
|
65
|
-
options[:tags] = normalize_tags(options[:tags]) if options[:tags]
|
66
|
-
options[:capabilities] ||= ["CAPABILITY_NAMED_IAM"]
|
67
|
-
delete if force
|
68
59
|
handling_cf_errors do
|
69
60
|
cf_client.create_change_set(options)
|
70
61
|
loop do
|
@@ -74,12 +65,12 @@ module Stackup
|
|
74
65
|
when /COMPLETE/
|
75
66
|
return current.status
|
76
67
|
when "FAILED"
|
77
|
-
if allow_empty_change_set
|
68
|
+
if allow_empty_change_set && (current.status_reason == "The submitted information didn't contain changes. Submit different information to create a change set.")
|
78
69
|
return current.status_reason
|
79
|
-
else
|
80
|
-
logger.error(current.status_reason)
|
81
|
-
raise StackUpdateError, "change-set creation failed" if status == "FAILED"
|
82
70
|
end
|
71
|
+
|
72
|
+
logger.error(current.status_reason)
|
73
|
+
raise StackUpdateError, "change-set creation failed" if status == "FAILED"
|
83
74
|
end
|
84
75
|
sleep(wait_poll_interval)
|
85
76
|
end
|
@@ -150,6 +141,21 @@ module Stackup
|
|
150
141
|
stack.send(:wait_poll_interval)
|
151
142
|
end
|
152
143
|
|
144
|
+
def validate_options(original)
|
145
|
+
options = original.dup
|
146
|
+
options[:stack_name] = stack.name
|
147
|
+
options[:change_set_name] = name
|
148
|
+
options[:change_set_type] = stack.exists? ? "UPDATE" : "CREATE"
|
149
|
+
options[:template_body] = MultiJson.dump(options.delete(:template)) if options[:template]
|
150
|
+
# optionally override template_body with the original template to preserve formatting (& comments in YAML)
|
151
|
+
template_orig = options.delete(:template_orig)
|
152
|
+
options[:template_body] = template_orig if options.delete(:preserve)
|
153
|
+
options[:parameters] = Parameters.new(options[:parameters]).to_a if options[:parameters]
|
154
|
+
options[:tags] = normalize_tags(options[:tags]) if options[:tags]
|
155
|
+
options[:capabilities] ||= ["CAPABILITY_NAMED_IAM"]
|
156
|
+
options
|
157
|
+
end
|
158
|
+
|
153
159
|
end
|
154
160
|
|
155
161
|
end
|
data/lib/stackup/differ.rb
CHANGED
data/lib/stackup/errors.rb
CHANGED
data/lib/stackup/main_command.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "clamp"
|
2
4
|
require "console_logger"
|
3
5
|
require "multi_json"
|
@@ -203,9 +205,7 @@ module Stackup
|
|
203
205
|
:multivalued => true, :default => ["CAPABILITY_NAMED_IAM"]
|
204
206
|
|
205
207
|
def execute
|
206
|
-
unless template_source || use_previous_template?
|
207
|
-
signal_usage_error "Specify either --template or --use-previous-template"
|
208
|
-
end
|
208
|
+
signal_usage_error "Specify either --template or --use-previous-template" unless template_source || use_previous_template?
|
209
209
|
options = {}
|
210
210
|
if template_source
|
211
211
|
if template_source.s3?
|
@@ -248,8 +248,6 @@ module Stackup
|
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
-
private
|
252
|
-
|
253
251
|
def pad(s, width)
|
254
252
|
(s || "").ljust(width)
|
255
253
|
end
|
@@ -299,9 +297,7 @@ module Stackup
|
|
299
297
|
:multivalued => true, :default => ["CAPABILITY_NAMED_IAM"]
|
300
298
|
|
301
299
|
def execute
|
302
|
-
unless template_source || use_previous_template?
|
303
|
-
signal_usage_error "Specify either --template or --use-previous-template"
|
304
|
-
end
|
300
|
+
signal_usage_error "Specify either --template or --use-previous-template" unless template_source || use_previous_template?
|
305
301
|
options = {}
|
306
302
|
if template_source
|
307
303
|
if template_source.s3?
|
@@ -363,8 +359,6 @@ module Stackup
|
|
363
359
|
|
364
360
|
end
|
365
361
|
|
366
|
-
private
|
367
|
-
|
368
362
|
def change_set
|
369
363
|
stack.change_set(change_set_name)
|
370
364
|
end
|
@@ -406,8 +400,6 @@ module Stackup
|
|
406
400
|
puts differ.diff(current, planned, context_lines)
|
407
401
|
end
|
408
402
|
|
409
|
-
private
|
410
|
-
|
411
403
|
def differ
|
412
404
|
Stackup::Differ.new(diff_format, &method(:format_data))
|
413
405
|
end
|
@@ -468,8 +460,6 @@ module Stackup
|
|
468
460
|
end
|
469
461
|
end
|
470
462
|
|
471
|
-
private
|
472
|
-
|
473
463
|
def display_event(e)
|
474
464
|
if data?
|
475
465
|
display_data(event_data(e))
|
data/lib/stackup/parameters.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Stackup
|
2
4
|
|
3
5
|
# Parameters to a CloudFormation template.
|
@@ -17,12 +19,12 @@ module Stackup
|
|
17
19
|
def hashify(parameters)
|
18
20
|
{}.tap do |result|
|
19
21
|
parameters.each do |p|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
|
23
|
+
p_struct = ParameterStruct.new(p)
|
24
|
+
result[p_struct.key] = p_struct.value
|
25
|
+
rescue ArgumentError
|
26
|
+
raise ArgumentError, "invalid parameter record: #{p.inspect}"
|
27
|
+
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
data/lib/stackup/rake_tasks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rake/tasklib"
|
2
4
|
require "tempfile"
|
3
5
|
require "yaml"
|
@@ -39,8 +41,7 @@ module Stackup
|
|
39
41
|
def define
|
40
42
|
namespace(name) do
|
41
43
|
|
42
|
-
data_options = []
|
43
|
-
data_options << DataOption.for("--template", template)
|
44
|
+
data_options = [DataOption.for("--template", template)]
|
44
45
|
data_options << DataOption.for("--parameters", parameters) if parameters
|
45
46
|
data_options << DataOption.for("--tags", tags) if tags
|
46
47
|
|
data/lib/stackup/service.rb
CHANGED
data/lib/stackup/source.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "aws-sdk-cloudformation"
|
2
4
|
|
3
5
|
module Stackup
|
@@ -14,10 +16,9 @@ module Stackup
|
|
14
16
|
|
15
17
|
attr_accessor :stack
|
16
18
|
|
17
|
-
# rubocop:disable Lint/HandleExceptions
|
18
|
-
|
19
19
|
# Yield all events since the last call
|
20
20
|
#
|
21
|
+
# rubocop:disable Lint/SuppressedException
|
21
22
|
def each_new_event
|
22
23
|
new_events = []
|
23
24
|
stack.events.each do |event|
|
@@ -40,8 +41,7 @@ module Stackup
|
|
40
41
|
nil
|
41
42
|
rescue Aws::CloudFormation::Errors::ValidationError
|
42
43
|
end
|
43
|
-
|
44
|
-
# rubocop:enable Lint/HandleExceptions
|
44
|
+
# rubocop:enable Lint/SuppressedException
|
45
45
|
|
46
46
|
private
|
47
47
|
|
data/lib/stackup/utils.rb
CHANGED
data/lib/stackup/version.rb
CHANGED
data/lib/stackup/yaml.rb
CHANGED
data/lib/stackup.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "stackup/main_command"
|
2
4
|
|
3
5
|
describe Stackup::MainCommand do
|
4
6
|
|
5
|
-
let(:mock_change_set) { double
|
7
|
+
let(:mock_change_set) { double }
|
6
8
|
|
7
9
|
before(:example) do
|
8
|
-
mock_stackup = double
|
9
|
-
mock_stack = double
|
10
|
+
mock_stackup = double
|
11
|
+
mock_stack = double
|
10
12
|
allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
|
11
13
|
allow(mock_stackup).to receive(:stack).and_return(mock_stack)
|
12
14
|
allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
|
@@ -15,41 +17,44 @@ describe Stackup::MainCommand do
|
|
15
17
|
context "change-set create --service-role-arn" do
|
16
18
|
it "invokes stack.change_set.create with role arn passed through" do
|
17
19
|
expected_args = {
|
18
|
-
role_arn
|
20
|
+
:role_arn => "arn:aws:iam::000000000000:role/example"
|
19
21
|
}
|
20
22
|
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
21
23
|
|
22
24
|
Stackup::MainCommand.run("stackup", [
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
"STACK-NAME", "change-set", "create",
|
26
|
+
"--template", "examples/template.yml",
|
27
|
+
"--service-role-arn", "arn:aws:iam::000000000000:role/example"
|
28
|
+
])
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
29
32
|
context "change-set create" do
|
30
33
|
it "invokes stack.change_set.create with allow_empty_change_set nil" do
|
31
34
|
expected_args = {
|
32
|
-
allow_empty_change_set
|
35
|
+
:allow_empty_change_set => nil
|
33
36
|
}
|
34
37
|
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
35
38
|
|
36
39
|
Stackup::MainCommand.run("stackup", [
|
37
|
-
|
38
|
-
|
40
|
+
"STACK-NAME", "change-set", "create",
|
41
|
+
"--template", "examples/template.yml"
|
42
|
+
])
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
context "change-set create --no-fail-on-empty-change-set" do
|
43
47
|
it "invokes stack.change_set.create with allow_empty_change_set true" do
|
44
48
|
expected_args = {
|
45
|
-
allow_empty_change_set
|
49
|
+
:allow_empty_change_set => true
|
46
50
|
}
|
47
51
|
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
48
52
|
|
49
53
|
Stackup::MainCommand.run("stackup", [
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
"STACK-NAME", "change-set", "create",
|
55
|
+
"--template", "examples/template.yml",
|
56
|
+
"--no-fail-on-empty-change-set"
|
57
|
+
])
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
data/spec/stackup/source_spec.rb
CHANGED
data/spec/stackup/stack_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
require "stackup/stack"
|
@@ -432,9 +434,9 @@ describe Stackup::Stack do
|
|
432
434
|
context "when allow_empty_change_set is nil and there are no changes" do
|
433
435
|
it "raises an exception" do
|
434
436
|
cf_client.stub_responses(:describe_change_set, [{
|
435
|
-
|
436
|
-
|
437
|
-
|
437
|
+
:status => "FAILED",
|
438
|
+
:status_reason => "The submitted information didn't contain changes. Submit different information to create a change set."
|
439
|
+
}])
|
438
440
|
expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
|
439
441
|
end
|
440
442
|
end
|
@@ -442,9 +444,9 @@ describe Stackup::Stack do
|
|
442
444
|
context "when allow_empty_change_set is true and there are no changes" do
|
443
445
|
it "does not raise an exception" do
|
444
446
|
cf_client.stub_responses(:describe_change_set, [{
|
445
|
-
|
446
|
-
|
447
|
-
|
447
|
+
:status => "FAILED",
|
448
|
+
:status_reason => "The submitted information didn't contain changes. Submit different information to create a change set."
|
449
|
+
}])
|
448
450
|
options[:allow_empty_change_set] = true
|
449
451
|
expect { create_change_set }.not_to raise_error
|
450
452
|
end
|
@@ -453,9 +455,9 @@ describe Stackup::Stack do
|
|
453
455
|
context "when allow_empty_change_set is true and there is some other failure" do
|
454
456
|
it "raises an exception" do
|
455
457
|
cf_client.stub_responses(:describe_change_set, [{
|
456
|
-
|
457
|
-
|
458
|
-
|
458
|
+
:status => "FAILED",
|
459
|
+
:status_reason => "some other failure message"
|
460
|
+
}])
|
459
461
|
options[:allow_empty_change_set] = true
|
460
462
|
expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
|
461
463
|
end
|
data/spec/stackup/utils_spec.rb
CHANGED
data/spec/stackup/yaml_spec.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
- Arvind Kunday
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-cloudformation
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
-
description:
|
84
|
+
description:
|
85
85
|
email:
|
86
86
|
- mike.williams@rea-group.com
|
87
87
|
- arvind.kunday@rea-group.com
|
@@ -122,23 +122,23 @@ homepage: https://github.com/realestate-com-au/stackup
|
|
122
122
|
licenses:
|
123
123
|
- MIT
|
124
124
|
metadata: {}
|
125
|
-
post_install_message:
|
125
|
+
post_install_message:
|
126
126
|
rdoc_options: []
|
127
127
|
require_paths:
|
128
128
|
- lib
|
129
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - "
|
131
|
+
- - "~>"
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
133
|
+
version: '2.6'
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.0.3
|
141
|
-
signing_key:
|
140
|
+
rubygems_version: 3.0.3.1
|
141
|
+
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Manage CloudFormation stacks
|
144
144
|
test_files:
|