stack_master 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +208 -0
- data/Rakefile +11 -0
- data/apply_demo.gif +0 -0
- data/bin/stack_master +16 -0
- data/example/simple/Gemfile +3 -0
- data/example/simple/parameters/myapp_vpc.yml +1 -0
- data/example/simple/parameters/myapp_web.yml +2 -0
- data/example/simple/stack_master.yml +13 -0
- data/example/simple/templates/myapp_vpc.rb +39 -0
- data/example/simple/templates/myapp_web.rb +16 -0
- data/features/apply.feature +241 -0
- data/features/delete.feature +43 -0
- data/features/diff.feature +191 -0
- data/features/events.feature +38 -0
- data/features/init.feature +6 -0
- data/features/outputs.feature +49 -0
- data/features/region_aliases.feature +66 -0
- data/features/resources.feature +45 -0
- data/features/stack_defaults.feature +88 -0
- data/features/status.feature +124 -0
- data/features/step_definitions/stack_steps.rb +50 -0
- data/features/support/env.rb +14 -0
- data/lib/stack_master.rb +81 -0
- data/lib/stack_master/aws_driver/cloud_formation.rb +56 -0
- data/lib/stack_master/cli.rb +164 -0
- data/lib/stack_master/command.rb +13 -0
- data/lib/stack_master/commands/apply.rb +104 -0
- data/lib/stack_master/commands/delete.rb +53 -0
- data/lib/stack_master/commands/diff.rb +31 -0
- data/lib/stack_master/commands/events.rb +39 -0
- data/lib/stack_master/commands/init.rb +109 -0
- data/lib/stack_master/commands/list_stacks.rb +16 -0
- data/lib/stack_master/commands/outputs.rb +27 -0
- data/lib/stack_master/commands/resources.rb +33 -0
- data/lib/stack_master/commands/status.rb +47 -0
- data/lib/stack_master/commands/validate.rb +17 -0
- data/lib/stack_master/config.rb +86 -0
- data/lib/stack_master/ctrl_c.rb +4 -0
- data/lib/stack_master/parameter_loader.rb +17 -0
- data/lib/stack_master/parameter_resolver.rb +45 -0
- data/lib/stack_master/parameter_resolvers/secret.rb +42 -0
- data/lib/stack_master/parameter_resolvers/security_group.rb +20 -0
- data/lib/stack_master/parameter_resolvers/sns_topic_name.rb +29 -0
- data/lib/stack_master/parameter_resolvers/stack_output.rb +53 -0
- data/lib/stack_master/prompter.rb +14 -0
- data/lib/stack_master/security_group_finder.rb +29 -0
- data/lib/stack_master/sns_topic_finder.rb +27 -0
- data/lib/stack_master/stack.rb +96 -0
- data/lib/stack_master/stack_definition.rb +49 -0
- data/lib/stack_master/stack_differ.rb +80 -0
- data/lib/stack_master/stack_events/fetcher.rb +45 -0
- data/lib/stack_master/stack_events/presenter.rb +27 -0
- data/lib/stack_master/stack_events/streamer.rb +55 -0
- data/lib/stack_master/stack_states.rb +34 -0
- data/lib/stack_master/template_compiler.rb +21 -0
- data/lib/stack_master/test_driver/cloud_formation.rb +139 -0
- data/lib/stack_master/testing.rb +7 -0
- data/lib/stack_master/utils.rb +31 -0
- data/lib/stack_master/validator.rb +25 -0
- data/lib/stack_master/version.rb +3 -0
- data/logo.png +0 -0
- data/script/buildkite/bundle.sh +5 -0
- data/script/buildkite/clean.sh +3 -0
- data/script/buildkite_rspec.sh +27 -0
- data/spec/fixtures/parameters/myapp_vpc.yml +1 -0
- data/spec/fixtures/stack_master.yml +35 -0
- data/spec/fixtures/templates/myapp_vpc.json +1 -0
- data/spec/spec_helper.rb +99 -0
- data/spec/stack_master/commands/apply_spec.rb +92 -0
- data/spec/stack_master/commands/delete_spec.rb +40 -0
- data/spec/stack_master/commands/init_spec.rb +17 -0
- data/spec/stack_master/commands/status_spec.rb +38 -0
- data/spec/stack_master/commands/validate_spec.rb +26 -0
- data/spec/stack_master/config_spec.rb +81 -0
- data/spec/stack_master/parameter_loader_spec.rb +81 -0
- data/spec/stack_master/parameter_resolver_spec.rb +58 -0
- data/spec/stack_master/parameter_resolvers/secret_spec.rb +66 -0
- data/spec/stack_master/parameter_resolvers/security_group_spec.rb +17 -0
- data/spec/stack_master/parameter_resolvers/sns_topic_name_spec.rb +43 -0
- data/spec/stack_master/parameter_resolvers/stack_output_spec.rb +77 -0
- data/spec/stack_master/security_group_finder_spec.rb +49 -0
- data/spec/stack_master/sns_topic_finder_spec.rb +25 -0
- data/spec/stack_master/stack_definition_spec.rb +37 -0
- data/spec/stack_master/stack_differ_spec.rb +34 -0
- data/spec/stack_master/stack_events/fetcher_spec.rb +65 -0
- data/spec/stack_master/stack_events/presenter_spec.rb +18 -0
- data/spec/stack_master/stack_events/streamer_spec.rb +33 -0
- data/spec/stack_master/stack_spec.rb +157 -0
- data/spec/stack_master/template_compiler_spec.rb +48 -0
- data/spec/stack_master/test_driver/cloud_formation_spec.rb +24 -0
- data/spec/stack_master/utils_spec.rb +30 -0
- data/spec/stack_master/validator_spec.rb +38 -0
- data/stack_master.gemspec +38 -0
- data/stacktemplates/parameter_region.yml +3 -0
- data/stacktemplates/parameter_stack_name.yml +3 -0
- data/stacktemplates/stack.json.erb +20 -0
- data/stacktemplates/stack_master.yml.erb +6 -0
- metadata +427 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: Delete command
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I set the environment variables to:
|
5
|
+
| variable | value |
|
6
|
+
| STUB_AWS | true |
|
7
|
+
|
8
|
+
Scenario: Run a delete command on a stack that exists
|
9
|
+
Given I set the environment variables to:
|
10
|
+
| variable | value |
|
11
|
+
| ANSWER | y |
|
12
|
+
And I stub the following stacks:
|
13
|
+
| stack_id | stack_name | parameters | region |
|
14
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
|
15
|
+
And I stub the following stack events:
|
16
|
+
| stack_id | event_id | stack_name | logical_resource_id | resource_status | resource_type | timestamp |
|
17
|
+
| 1 | 1 | myapp-vpc | myapp-vpc | DELETE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
|
18
|
+
When I run `stack_master delete us-east-1 myapp-vpc --trace` interactively
|
19
|
+
And the output should contain all of these lines:
|
20
|
+
| 2020-10-29 00:00:00 +1100 myapp-vpc AWS::CloudFormation::Stack DELETE_COMPLETE |
|
21
|
+
Then the exit status should be 0
|
22
|
+
|
23
|
+
Scenario: Run a delete command on a stack that does not exists
|
24
|
+
Given I set the environment variables to:
|
25
|
+
| variable | value |
|
26
|
+
| ANSWER | y |
|
27
|
+
When I run `stack_master delete us-east-1 myapp-vpc --trace` interactively
|
28
|
+
And the output should contain all of these lines:
|
29
|
+
| Stack does not exist |
|
30
|
+
Then the exit status should be 0
|
31
|
+
|
32
|
+
Scenario: Answer no when asked to delete stack
|
33
|
+
Given I set the environment variables to:
|
34
|
+
| variable | value |
|
35
|
+
| ANSWER | n |
|
36
|
+
And I stub the following stacks:
|
37
|
+
| stack_id | stack_name | parameters | region |
|
38
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
|
39
|
+
When I run `stack_master delete us-east-1 myapp-vpc --trace` interactively
|
40
|
+
And the output should contain all of these lines:
|
41
|
+
| Stack update aborted |
|
42
|
+
Then the exit status should be 0
|
43
|
+
|
@@ -0,0 +1,191 @@
|
|
1
|
+
Feature: Diff command
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
stacks:
|
7
|
+
us_east_1:
|
8
|
+
myapp_vpc:
|
9
|
+
template: myapp_vpc.json
|
10
|
+
"""
|
11
|
+
And a directory named "parameters"
|
12
|
+
And a file named "parameters/myapp_vpc.yml" with:
|
13
|
+
"""
|
14
|
+
KeyName: my-key
|
15
|
+
"""
|
16
|
+
And a directory named "templates"
|
17
|
+
And a file named "templates/myapp_vpc.json" with:
|
18
|
+
"""
|
19
|
+
{
|
20
|
+
"Description": "Test template",
|
21
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
22
|
+
"Parameters": {
|
23
|
+
"KeyName": {
|
24
|
+
"Description": "Key Name",
|
25
|
+
"Type": "String"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"Resources": {
|
29
|
+
"TestSg": {
|
30
|
+
"Type": "AWS::EC2::SecurityGroup",
|
31
|
+
"Properties": {
|
32
|
+
"GroupDescription": "Test SG",
|
33
|
+
"VpcId": {
|
34
|
+
"Ref": "VpcId"
|
35
|
+
}
|
36
|
+
}
|
37
|
+
},
|
38
|
+
"TestSg2": {
|
39
|
+
"Type": "AWS::EC2::SecurityGroup",
|
40
|
+
"Properties": {
|
41
|
+
"GroupDescription": "Test SG 2",
|
42
|
+
"VpcId": {
|
43
|
+
"Ref": "VpcId"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
"""
|
50
|
+
And I set the environment variables to:
|
51
|
+
| variable | value |
|
52
|
+
| STUB_AWS | true |
|
53
|
+
|
54
|
+
Scenario: Run diff on a stack with no changes
|
55
|
+
Given I set the environment variables to:
|
56
|
+
| variable | value |
|
57
|
+
| ANSWER | y |
|
58
|
+
And I stub the following stacks:
|
59
|
+
| stack_id | stack_name | parameters | region |
|
60
|
+
| 1 | myapp-vpc | KeyName=changed-key | us-east-1 |
|
61
|
+
And I stub a template for the stack "myapp-vpc":
|
62
|
+
"""
|
63
|
+
{
|
64
|
+
"Description": "Test template",
|
65
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
66
|
+
"Parameters": {
|
67
|
+
"KeyName": {
|
68
|
+
"Description": "Key Name",
|
69
|
+
"Type": "String"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
"Resources": {
|
73
|
+
"TestSg": {
|
74
|
+
"Type": "AWS::EC2::SecurityGroup",
|
75
|
+
"Properties": {
|
76
|
+
"GroupDescription": "Test SG",
|
77
|
+
"VpcId": {
|
78
|
+
"Ref": "VpcId"
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"TestSg2": {
|
83
|
+
"Type": "AWS::EC2::SecurityGroup",
|
84
|
+
"Properties": {
|
85
|
+
"GroupDescription": "Test SG 2",
|
86
|
+
"VpcId": {
|
87
|
+
"Ref": "VpcId"
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
"""
|
94
|
+
When I run `stack_master diff us-east-1 myapp-vpc --trace` interactively
|
95
|
+
And the output should contain all of these lines:
|
96
|
+
| -KeyName: changed |
|
97
|
+
| +KeyName: my-key |
|
98
|
+
Then the exit status should be 0
|
99
|
+
|
100
|
+
Scenario: Run diff on a stack with parameter changes
|
101
|
+
Given I set the environment variables to:
|
102
|
+
| variable | value |
|
103
|
+
| ANSWER | y |
|
104
|
+
And I stub the following stacks:
|
105
|
+
| stack_id | stack_name | parameters | region |
|
106
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
|
107
|
+
And I stub a template for the stack "myapp-vpc":
|
108
|
+
"""
|
109
|
+
{
|
110
|
+
"Description": "Test template",
|
111
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
112
|
+
"Parameters": {
|
113
|
+
"KeyName": {
|
114
|
+
"Description": "Key Name",
|
115
|
+
"Type": "String"
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"Resources": {
|
119
|
+
"TestSg": {
|
120
|
+
"Type": "AWS::EC2::SecurityGroup",
|
121
|
+
"Properties": {
|
122
|
+
"GroupDescription": "Test SG",
|
123
|
+
"VpcId": {
|
124
|
+
"Ref": "VpcId"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
},
|
128
|
+
"TestSg2": {
|
129
|
+
"Type": "AWS::EC2::SecurityGroup",
|
130
|
+
"Properties": {
|
131
|
+
"GroupDescription": "Test SG 2",
|
132
|
+
"VpcId": {
|
133
|
+
"Ref": "VpcId"
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
"""
|
140
|
+
When I run `stack_master diff us-east-1 myapp-vpc --trace` interactively
|
141
|
+
And the output should contain all of these lines:
|
142
|
+
| Stack diff: No changes |
|
143
|
+
| Parameters diff: No changes |
|
144
|
+
Then the exit status should be 0
|
145
|
+
|
146
|
+
Scenario: Run diff on a stack with template changes
|
147
|
+
Given I set the environment variables to:
|
148
|
+
| variable | value |
|
149
|
+
| ANSWER | y |
|
150
|
+
And I stub the following stacks:
|
151
|
+
| stack_id | stack_name | parameters | region |
|
152
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
|
153
|
+
And I stub a template for the stack "myapp-vpc":
|
154
|
+
"""
|
155
|
+
{
|
156
|
+
"Description": "Test template",
|
157
|
+
"AWSTemplateFormatVersion": "2010-09-09",
|
158
|
+
"Parameters": {
|
159
|
+
"KeyName": {
|
160
|
+
"Description": "Key Name",
|
161
|
+
"Type": "String"
|
162
|
+
}
|
163
|
+
},
|
164
|
+
"Resources": {
|
165
|
+
"TestSg": {
|
166
|
+
"Type": "AWS::EC2::SecurityGroup",
|
167
|
+
"Properties": {
|
168
|
+
"GroupDescription": "Test SG",
|
169
|
+
"VpcId": {
|
170
|
+
"Ref": "VpcId"
|
171
|
+
}
|
172
|
+
}
|
173
|
+
},
|
174
|
+
"TestSg2": {
|
175
|
+
"Type": "AWS::EC2::SecurityGroup",
|
176
|
+
"Properties": {
|
177
|
+
"GroupDescription": "Changed description",
|
178
|
+
"VpcId": {
|
179
|
+
"Ref": "VpcId"
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
"""
|
186
|
+
When I run `stack_master diff us-east-1 myapp-vpc --trace` interactively
|
187
|
+
And the output should contain all of these lines:
|
188
|
+
| - "GroupDescription": "Changed description" |
|
189
|
+
| + "GroupDescription": "Test SG 2", |
|
190
|
+
Then the exit status should be 0
|
191
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Events command
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
stacks:
|
7
|
+
us_east_1:
|
8
|
+
myapp_vpc:
|
9
|
+
template: myapp_vpc.rb
|
10
|
+
"""
|
11
|
+
And a directory named "templates"
|
12
|
+
And a file named "templates/myapp_vpc.rb" with:
|
13
|
+
"""
|
14
|
+
SparkleFormation.new(:myapp_vpc) do
|
15
|
+
description "Test template"
|
16
|
+
set!('AWSTemplateFormatVersion', '2010-09-09')
|
17
|
+
|
18
|
+
resources.vpc do
|
19
|
+
type 'AWS::EC2::VPC'
|
20
|
+
properties do
|
21
|
+
cidr_block '10.200.0.0/16'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
"""
|
26
|
+
And I set the environment variables to:
|
27
|
+
| variable | value |
|
28
|
+
| STUB_AWS | true |
|
29
|
+
| ANSWER | y |
|
30
|
+
|
31
|
+
Scenario: View events
|
32
|
+
And I stub the following stack events:
|
33
|
+
| stack_id | event_id | stack_name | logical_resource_id | resource_status | resource_type | timestamp |
|
34
|
+
| 1 | 1 | myapp-vpc | TestSg | CREATE_COMPLETE | AWS::EC2::SecurityGroup | 2020-10-29 00:00:00 |
|
35
|
+
| 1 | 1 | myapp-vpc | myapp-vpc | CREATE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
|
36
|
+
When I run `stack_master events us-east-1 myapp-vpc --trace`
|
37
|
+
And the output should contain all of these lines:
|
38
|
+
| 2020-10-29 00:00:00 +1100 myapp-vpc AWS::CloudFormation::Stack CREATE_COMPLETE |
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Feature: Outputs command
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
stacks:
|
7
|
+
us_east_1:
|
8
|
+
myapp_vpc:
|
9
|
+
template: myapp_vpc.rb
|
10
|
+
"""
|
11
|
+
And a directory named "templates"
|
12
|
+
And a file named "templates/myapp_vpc.rb" with:
|
13
|
+
"""
|
14
|
+
SparkleFormation.new(:myapp_vpc) do
|
15
|
+
description "Test template"
|
16
|
+
set!('AWSTemplateFormatVersion', '2010-09-09')
|
17
|
+
resources.vpc do
|
18
|
+
type 'AWS::EC2::VPC'
|
19
|
+
properties do
|
20
|
+
cidr_block '10.200.0.0/16'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And I set the environment variables to:
|
26
|
+
| variable | value |
|
27
|
+
| STUB_AWS | true |
|
28
|
+
| ANSWER | y |
|
29
|
+
|
30
|
+
Scenario: Output stack resources
|
31
|
+
And I stub the following stacks:
|
32
|
+
| stack_id | stack_name | parameters | region | outputs |
|
33
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 | VpcId=vpc-123456 |
|
34
|
+
And I stub a template for the stack "myapp-vpc":
|
35
|
+
"""
|
36
|
+
{
|
37
|
+
}
|
38
|
+
"""
|
39
|
+
When I run `stack_master outputs us-east-1 myapp-vpc --trace`
|
40
|
+
And the output should contain all of these lines:
|
41
|
+
| VpcId |
|
42
|
+
| vpc-123456 |
|
43
|
+
|
44
|
+
Scenario: Fails when the stack doesn't exist
|
45
|
+
When I run `stack_master outputs us-east-1 myapp-vpc --trace`
|
46
|
+
And the output should not contain all of these lines:
|
47
|
+
| VpcId |
|
48
|
+
| vpc-123456 |
|
49
|
+
And the output should contain "Stack doesn't exist"
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: Region aliases
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
region_aliases:
|
7
|
+
staging: ap-southeast-2
|
8
|
+
production: us_east_1
|
9
|
+
stacks:
|
10
|
+
staging:
|
11
|
+
myapp_vpc:
|
12
|
+
template: myapp_vpc.rb
|
13
|
+
production:
|
14
|
+
myapp_vpc:
|
15
|
+
template: myapp_vpc.rb
|
16
|
+
"""
|
17
|
+
And a directory named "templates"
|
18
|
+
And a directory named "parameters"
|
19
|
+
And a file named "templates/myapp_vpc.rb" with:
|
20
|
+
"""
|
21
|
+
SparkleFormation.new(:myapp_vpc) do
|
22
|
+
description "Test template"
|
23
|
+
set!('AWSTemplateFormatVersion', '2010-09-09')
|
24
|
+
|
25
|
+
parameters.key_name do
|
26
|
+
description 'Key name'
|
27
|
+
type 'String'
|
28
|
+
end
|
29
|
+
|
30
|
+
resources.vpc do
|
31
|
+
type 'AWS::EC2::VPC'
|
32
|
+
properties do
|
33
|
+
cidr_block '10.200.0.0/16'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
outputs do
|
38
|
+
vpc_id do
|
39
|
+
description 'A VPC ID'
|
40
|
+
value ref!(:vpc)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
"""
|
45
|
+
And a file named "parameters/myapp_vpc.yml" with:
|
46
|
+
"""
|
47
|
+
key_name: my-key
|
48
|
+
"""
|
49
|
+
And I stub the following stack events:
|
50
|
+
| stack_id | event_id | stack_name | logical_resource_id | resource_status | resource_type | timestamp |
|
51
|
+
| 1 | 1 | myapp-vpc | TestSg | CREATE_COMPLETE | AWS::EC2::SecurityGroup | 2020-10-29 00:00:00 |
|
52
|
+
| 1 | 1 | myapp-vpc | myapp-vpc | CREATE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
|
53
|
+
And I set the environment variables to:
|
54
|
+
| variable | value |
|
55
|
+
| STUB_AWS | true |
|
56
|
+
| ANSWER | y |
|
57
|
+
|
58
|
+
Scenario: Create a stack using region aliases
|
59
|
+
When I run `stack_master apply staging myapp-vpc --trace`
|
60
|
+
And the output should contain all of these lines:
|
61
|
+
| Stack diff: |
|
62
|
+
| + "Vpc": { |
|
63
|
+
| Parameters diff: |
|
64
|
+
| KeyName: my-key |
|
65
|
+
| 2020-10-29 00:00:00 +1100 myapp-vpc AWS::CloudFormation::Stack CREATE_COMPLETE |
|
66
|
+
Then the exit status should be 0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Feature: Resources command
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
stacks:
|
7
|
+
us_east_1:
|
8
|
+
myapp_vpc:
|
9
|
+
template: myapp_vpc.rb
|
10
|
+
"""
|
11
|
+
And a directory named "templates"
|
12
|
+
And a file named "templates/myapp_vpc.rb" with:
|
13
|
+
"""
|
14
|
+
SparkleFormation.new(:myapp_vpc) do
|
15
|
+
description "Test template"
|
16
|
+
set!('AWSTemplateFormatVersion', '2010-09-09')
|
17
|
+
resources.vpc do
|
18
|
+
type 'AWS::EC2::VPC'
|
19
|
+
properties do
|
20
|
+
cidr_block '10.200.0.0/16'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And I set the environment variables to:
|
26
|
+
| variable | value |
|
27
|
+
| STUB_AWS | true |
|
28
|
+
|
29
|
+
Scenario: Show resources
|
30
|
+
And I stub the following stacks:
|
31
|
+
| stack_id | stack_name | parameters | region |
|
32
|
+
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
|
33
|
+
And I stub the following stack resources:
|
34
|
+
| stack_name | logical_resource_id | resource_type | timestamp | resource_status |
|
35
|
+
| myapp-vpc | Vpc | AWS::EC2::Vpc | 2015-11-02 06:41:58 | CREATE_COMPLETE |
|
36
|
+
When I run `stack_master resources us-east-1 myapp-vpc --trace`
|
37
|
+
And the output should contain all of these lines:
|
38
|
+
| Vpc |
|
39
|
+
| AWS::EC2::Vpc |
|
40
|
+
| 2015-11-02 06:41:58 |
|
41
|
+
| CREATE_COMPLETE |
|
42
|
+
|
43
|
+
Scenario: Fails when the stack doesn't exist
|
44
|
+
When I run `stack_master resources us-east-1 myapp-vpc --trace`
|
45
|
+
And the output should contain "Stack doesn't exist"
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: Stack defaults
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "stack_master.yml" with:
|
5
|
+
"""
|
6
|
+
stack_defaults:
|
7
|
+
tags:
|
8
|
+
application: my-awesome-blog
|
9
|
+
region_defaults:
|
10
|
+
ap_southeast_2:
|
11
|
+
notification_arns:
|
12
|
+
- test_arn_1
|
13
|
+
secret_file: staging.yml.gpg
|
14
|
+
tags:
|
15
|
+
environment: staging
|
16
|
+
stack_policy_file: my_policy.json
|
17
|
+
us_east_1:
|
18
|
+
notification_arns:
|
19
|
+
- test_arn_2
|
20
|
+
secret_file: production.yml.gpg
|
21
|
+
tags:
|
22
|
+
environment: production
|
23
|
+
stacks:
|
24
|
+
ap_southeast_2:
|
25
|
+
myapp_vpc:
|
26
|
+
template: myapp_vpc.rb
|
27
|
+
tags:
|
28
|
+
role: network
|
29
|
+
notification_arns:
|
30
|
+
- test_arn_3
|
31
|
+
us_east_1:
|
32
|
+
myapp_vpc:
|
33
|
+
template: myapp_vpc.rb
|
34
|
+
tags:
|
35
|
+
role: network
|
36
|
+
"""
|
37
|
+
And a directory named "templates"
|
38
|
+
And a directory named "policies"
|
39
|
+
And a file named "templates/myapp_vpc.rb" with:
|
40
|
+
"""
|
41
|
+
SparkleFormation.new(:myapp_vpc) do
|
42
|
+
description "Test template"
|
43
|
+
set!('AWSTemplateFormatVersion', '2010-09-09')
|
44
|
+
|
45
|
+
parameters.key_name do
|
46
|
+
description 'Key name'
|
47
|
+
type 'String'
|
48
|
+
default 'blah'
|
49
|
+
end
|
50
|
+
|
51
|
+
resources.vpc do
|
52
|
+
type 'AWS::EC2::VPC'
|
53
|
+
properties do
|
54
|
+
cidr_block '10.200.0.0/16'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
outputs do
|
59
|
+
vpc_id do
|
60
|
+
description 'A VPC ID'
|
61
|
+
value ref!(:vpc)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
And a file named "policies/my_policy.json" with:
|
67
|
+
"""
|
68
|
+
{my: 'policy'}
|
69
|
+
"""
|
70
|
+
And I stub the following stack events:
|
71
|
+
| stack_id | event_id | stack_name | logical_resource_id | resource_status | resource_type | timestamp |
|
72
|
+
| 1 | 1 | myapp-vpc | TestSg | CREATE_COMPLETE | AWS::EC2::SecurityGroup | 2020-10-29 00:00:00 |
|
73
|
+
| 1 | 1 | myapp-vpc | myapp-vpc | CREATE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
|
74
|
+
And I set the environment variables to:
|
75
|
+
| variable | value |
|
76
|
+
| STUB_AWS | true |
|
77
|
+
Given I set the environment variables to:
|
78
|
+
| variable | value |
|
79
|
+
| ANSWER | y |
|
80
|
+
|
81
|
+
Scenario: Create a stack with inherited attributes
|
82
|
+
When I run `stack_master apply ap-southeast-2 myapp-vpc --trace` interactively
|
83
|
+
Then the stack "myapp-vpc" should contain this notification ARN "test_arn_1"
|
84
|
+
Then the stack "myapp-vpc" should contain this notification ARN "test_arn_3"
|
85
|
+
And the stack "myapp-vpc" should have a policy with the following:
|
86
|
+
"""
|
87
|
+
{my: 'policy'}
|
88
|
+
"""
|