Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 67 additions & 10 deletions features/apply.feature
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,24 @@ Feature: Apply command
| 1 | 1 | myapp-vpc | myapp-vpc | CREATE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
When I run `stack_master apply us-east-1 myapp-vpc --trace`
And the output should contain all of these lines:
| Stack diff: |
| + "Vpc": { |
| Parameters diff: |
| KeyName: my-key |
| Stack diff: |
| + "Vpc": { |
| Parameters diff: |
| KeyName: my-key |
| Proposed change set: |
And the output should match /2020-10-29 00:00:00 (\+|\-)[0-9]{4} myapp-vpc AWS::CloudFormation::Stack CREATE_COMPLETE/
Then the exit status should be 0

Scenario: Run apply and don't create the stack
Given I will answer prompts with "n"
When I run `stack_master apply us-east-1 myapp-vpc --trace`
And the output should contain all of these lines:
| Stack diff: |
| + "Vpc": { |
| Parameters diff: |
| KeyName: my-key |
| aborted |
| Stack diff: |
| + "Vpc": { |
| Parameters diff: |
| KeyName: my-key |
| aborted |
| Proposed change set: |
And the output should not match /2020-10-29 00:00:00 (\+|\-)[0-9]{4} myapp-vpc AWS::CloudFormation::Stack CREATE_COMPLETE/
Then the exit status should be 0

Expand Down Expand Up @@ -211,7 +213,62 @@ Feature: Apply command
| Proposed change set: |
| Replace |
| ======================================== |
| Apply change set (y/n)? |
| Apply change set (y/n)? |
Then the exit status should be 0


Scenario: Run apply to update a stack and answer no
Given I will answer prompts with "n"
And I stub the following stack events:
| stack_id | event_id | stack_name | logical_resource_id | resource_status | resource_type | timestamp |
| 1 | 1 | myapp-vpc | TestSg | CREATE_COMPLETE | AWS::EC2::SecurityGroup | 2020-10-29 00:00:00 |
| 1 | 1 | myapp-vpc | myapp-vpc | CREATE_COMPLETE | AWS::CloudFormation::Stack | 2020-10-29 00:00:00 |
And I stub the following stacks:
| stack_id | stack_name | parameters | region |
| 1 | myapp-vpc | KeyName=my-key | us-east-1 |
And I stub a template for the stack "myapp-vpc":
"""
{
"Description": "Test template",
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"KeyName": {
"Description": "Key Name",
"Type": "String"
}
},
"Resources": {
"TestSg": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Test SG",
"VpcId": {
"Ref": "VpcId"
}
}
},
"TestSg2": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Test SG 2",
"VpcId": {
"Ref": "VpcId"
}
}
}
}
}
"""
When I run `stack_master apply us-east-1 myapp-vpc --trace`
And the output should contain all of these lines:
| Stack diff: |
| - "TestSg2": { |
| Parameters diff: No changes |
| ======================================== |
| Proposed change set: |
| Replace |
| ======================================== |
| Apply change set (y/n)? |
Then the exit status should be 0

Scenario: Update a stack that has changed with --changed
Expand Down
2 changes: 1 addition & 1 deletion lib/stack_master/commands/apply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def update_stack
halt!(@change_set.status_reason)
end

@change_set.display(StackMaster.stdout)
if differ.single_param_update?(@options.yes_param)
StackMaster.stdout.puts("Auto-approving update to single parameter #{@options.yes_param}")
else
ask_update_confirmation!
end
@change_set.display(StackMaster.stdout)
execute_change_set
end

Expand Down