stackup 1.5.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 +17 -0
- data/README.md +21 -12
- data/bin/stackup +3 -545
- data/lib/stackup/change_set.rb +24 -13
- 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 +551 -0
- 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 +3 -1
- 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 +61 -0
- data/spec/stackup/parameters_spec.rb +2 -0
- data/spec/stackup/rake_tasks_spec.rb +2 -0
- data/spec/stackup/source_spec.rb +12 -0
- data/spec/stackup/stack_spec.rb +51 -0
- 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 +12 -9
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 "open-uri"
|
2
4
|
require "stackup/stack"
|
3
5
|
|
@@ -15,7 +17,7 @@ module Stackup
|
|
15
17
|
|
16
18
|
def s3?
|
17
19
|
uri.scheme == "https" &&
|
18
|
-
uri.host =~ /(^|\.)s3(
|
20
|
+
uri.host =~ /(^|\.)s3((\.|-)\w+-\w+-\d)?\.amazonaws\.com$/
|
19
21
|
end
|
20
22
|
|
21
23
|
def body
|
@@ -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
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "stackup/main_command"
|
4
|
+
|
5
|
+
describe Stackup::MainCommand do
|
6
|
+
|
7
|
+
let(:mock_change_set) { double }
|
8
|
+
|
9
|
+
before(:example) do
|
10
|
+
mock_stackup = double
|
11
|
+
mock_stack = double
|
12
|
+
allow_any_instance_of(Stackup::MainCommand).to receive(:Stackup).and_return(mock_stackup)
|
13
|
+
allow(mock_stackup).to receive(:stack).and_return(mock_stack)
|
14
|
+
allow(mock_stack).to receive(:change_set).and_return(mock_change_set)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "change-set create --service-role-arn" do
|
18
|
+
it "invokes stack.change_set.create with role arn passed through" do
|
19
|
+
expected_args = {
|
20
|
+
:role_arn => "arn:aws:iam::000000000000:role/example"
|
21
|
+
}
|
22
|
+
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
23
|
+
|
24
|
+
Stackup::MainCommand.run("stackup", [
|
25
|
+
"STACK-NAME", "change-set", "create",
|
26
|
+
"--template", "examples/template.yml",
|
27
|
+
"--service-role-arn", "arn:aws:iam::000000000000:role/example"
|
28
|
+
])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "change-set create" do
|
33
|
+
it "invokes stack.change_set.create with allow_empty_change_set nil" do
|
34
|
+
expected_args = {
|
35
|
+
:allow_empty_change_set => nil
|
36
|
+
}
|
37
|
+
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
38
|
+
|
39
|
+
Stackup::MainCommand.run("stackup", [
|
40
|
+
"STACK-NAME", "change-set", "create",
|
41
|
+
"--template", "examples/template.yml"
|
42
|
+
])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "change-set create --no-fail-on-empty-change-set" do
|
47
|
+
it "invokes stack.change_set.create with allow_empty_change_set true" do
|
48
|
+
expected_args = {
|
49
|
+
:allow_empty_change_set => true
|
50
|
+
}
|
51
|
+
expect(mock_change_set).to receive(:create).with(hash_including(expected_args))
|
52
|
+
|
53
|
+
Stackup::MainCommand.run("stackup", [
|
54
|
+
"STACK-NAME", "change-set", "create",
|
55
|
+
"--template", "examples/template.yml",
|
56
|
+
"--no-fail-on-empty-change-set"
|
57
|
+
])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/spec/stackup/source_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
require "multi_json"
|
@@ -124,6 +126,16 @@ describe Stackup::Source do
|
|
124
126
|
|
125
127
|
end
|
126
128
|
|
129
|
+
context "with dot separated bucket and region" do
|
130
|
+
|
131
|
+
let(:s3_url) { "https://bucket.s3.us-east-1.amazonaws.com/cfn/template.yml" }
|
132
|
+
|
133
|
+
it "is S3" do
|
134
|
+
expect(subject).to be_s3
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
127
139
|
end
|
128
140
|
|
129
141
|
end
|
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"
|
@@ -342,6 +344,23 @@ describe Stackup::Stack do
|
|
342
344
|
.with(hash_including(expected_args))
|
343
345
|
end
|
344
346
|
|
347
|
+
it "passes options through to :create_change_set" do
|
348
|
+
options = {
|
349
|
+
:template_body => template,
|
350
|
+
:role_arn => "service role arn"
|
351
|
+
}
|
352
|
+
expected_args = {
|
353
|
+
:stack_name => stack_name,
|
354
|
+
:change_set_name => change_set_name,
|
355
|
+
:change_set_type => "CREATE",
|
356
|
+
:template_body => template,
|
357
|
+
:role_arn => "service role arn"
|
358
|
+
}
|
359
|
+
stack.change_set(change_set_name).create(options)
|
360
|
+
expect(cf_client).to have_received(:create_change_set)
|
361
|
+
.with(hash_including(expected_args))
|
362
|
+
end
|
363
|
+
|
345
364
|
context "with :template as data" do
|
346
365
|
|
347
366
|
let(:options) do
|
@@ -412,6 +431,38 @@ describe Stackup::Stack do
|
|
412
431
|
|
413
432
|
end
|
414
433
|
|
434
|
+
context "when allow_empty_change_set is nil and there are no changes" do
|
435
|
+
it "raises an exception" do
|
436
|
+
cf_client.stub_responses(:describe_change_set, [{
|
437
|
+
:status => "FAILED",
|
438
|
+
:status_reason => "The submitted information didn't contain changes. Submit different information to create a change set."
|
439
|
+
}])
|
440
|
+
expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
context "when allow_empty_change_set is true and there are no changes" do
|
445
|
+
it "does not raise an exception" do
|
446
|
+
cf_client.stub_responses(:describe_change_set, [{
|
447
|
+
:status => "FAILED",
|
448
|
+
:status_reason => "The submitted information didn't contain changes. Submit different information to create a change set."
|
449
|
+
}])
|
450
|
+
options[:allow_empty_change_set] = true
|
451
|
+
expect { create_change_set }.not_to raise_error
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
context "when allow_empty_change_set is true and there is some other failure" do
|
456
|
+
it "raises an exception" do
|
457
|
+
cf_client.stub_responses(:describe_change_set, [{
|
458
|
+
:status => "FAILED",
|
459
|
+
:status_reason => "some other failure message"
|
460
|
+
}])
|
461
|
+
options[:allow_empty_change_set] = true
|
462
|
+
expect { create_change_set }.to raise_error(Stackup::StackUpdateError)
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
415
466
|
end
|
416
467
|
|
417
468
|
describe "#change_set#execute" do
|
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.
|
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
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/stackup/differ.rb
|
100
100
|
- lib/stackup/error_handling.rb
|
101
101
|
- lib/stackup/errors.rb
|
102
|
+
- lib/stackup/main_command.rb
|
102
103
|
- lib/stackup/parameters.rb
|
103
104
|
- lib/stackup/rake_tasks.rb
|
104
105
|
- lib/stackup/service.rb
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- lib/stackup/version.rb
|
110
111
|
- lib/stackup/yaml.rb
|
111
112
|
- spec/spec_helper.rb
|
113
|
+
- spec/stackup/main_command_spec.rb
|
112
114
|
- spec/stackup/parameters_spec.rb
|
113
115
|
- spec/stackup/rake_tasks_spec.rb
|
114
116
|
- spec/stackup/source_spec.rb
|
@@ -120,27 +122,28 @@ homepage: https://github.com/realestate-com-au/stackup
|
|
120
122
|
licenses:
|
121
123
|
- MIT
|
122
124
|
metadata: {}
|
123
|
-
post_install_message:
|
125
|
+
post_install_message:
|
124
126
|
rdoc_options: []
|
125
127
|
require_paths:
|
126
128
|
- lib
|
127
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
130
|
requirements:
|
129
|
-
- - "
|
131
|
+
- - "~>"
|
130
132
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
133
|
+
version: '2.6'
|
132
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
135
|
requirements:
|
134
136
|
- - ">="
|
135
137
|
- !ruby/object:Gem::Version
|
136
138
|
version: '0'
|
137
139
|
requirements: []
|
138
|
-
rubygems_version: 3.0.3
|
139
|
-
signing_key:
|
140
|
+
rubygems_version: 3.0.3.1
|
141
|
+
signing_key:
|
140
142
|
specification_version: 4
|
141
143
|
summary: Manage CloudFormation stacks
|
142
144
|
test_files:
|
143
145
|
- spec/spec_helper.rb
|
146
|
+
- spec/stackup/main_command_spec.rb
|
144
147
|
- spec/stackup/parameters_spec.rb
|
145
148
|
- spec/stackup/rake_tasks_spec.rb
|
146
149
|
- spec/stackup/source_spec.rb
|