Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resolve #1493] Complete DisableRollback implementation #1494

Merged
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
1 change: 1 addition & 0 deletions sceptre/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def update_command(
:type verbose: bool
:param yes: A flag to answer 'yes' to all CLI questions.
:type yes: bool
:param disable_rollback: A flag to disable cloudformation rollback.
alex-harvey-z3q marked this conversation as resolved.
Show resolved Hide resolved
"""

context = SceptreContext(
Expand Down
6 changes: 6 additions & 0 deletions sceptre/plan/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ def update(self):
{"Key": str(k), "Value": str(v)} for k, v in self.stack.tags.items()
],
}

if self.stack.disable_rollback:
alex-harvey-z3q marked this conversation as resolved.
Show resolved Hide resolved
update_stack_kwargs.update(
{"DisableRollback": self.stack.disable_rollback}
)

update_stack_kwargs.update(self.stack.template.get_boto_call_parameter())
update_stack_kwargs.update(self._get_role_arn())
response = self.connection_manager.call(
Expand Down
38 changes: 38 additions & 0 deletions tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,44 @@ def test_update_sends_correct_request(self, mock_wait_for_completion):
sentinel.stack_timeout, boto_response=ANY
)

@patch("sceptre.plan.actions.StackActions._wait_for_completion")
@patch("sceptre.plan.actions.StackActions._get_stack_timeout")
def test_update_disable_rollback_overrides_on_failure(
self, mock_get_stack_timeout, mock_wait_for_completion
):
self.actions.stack._template = Mock(spec=Template)
self.actions.stack._template.get_boto_call_parameter.return_value = {
"Template": sentinel.template
}

self.actions.stack.on_failure = "ROLLBACK"
self.actions.stack.disable_rollback = True

mock_get_stack_timeout.return_value = {"TimeoutInMinutes": sentinel.timeout}

self.actions.update()
self.actions.connection_manager.call.assert_called_with(
service="cloudformation",
command="update_stack",
kwargs={
"StackName": sentinel.external_name,
"Template": sentinel.template,
"Parameters": [{"ParameterKey": "key1", "ParameterValue": "val1"}],
"Capabilities": [
"CAPABILITY_IAM",
"CAPABILITY_NAMED_IAM",
"CAPABILITY_AUTO_EXPAND",
],
"RoleARN": sentinel.cloudformation_service_role,
"NotificationARNs": [sentinel.notification],
"Tags": [{"Key": "tag1", "Value": "val1"}],
"DisableRollback": True,
},
)
mock_wait_for_completion.assert_called_once_with(
sentinel.stack_timeout, boto_response=ANY
)

@patch("sceptre.plan.actions.StackActions._wait_for_completion")
def test_update_cancels_after_timeout(self, mock_wait_for_completion):
self.actions.stack._template = Mock(spec=Template)
Expand Down