Skip to content

Commit

Permalink
Return the deployment result in exit code for all failures (aws#6258)
Browse files Browse the repository at this point in the history
Co-authored-by: Wing Fung Lau <[email protected]>
Co-authored-by: Haresh Nasit <[email protected]>
Co-authored-by: Daniel Mil <[email protected]>
  • Loading branch information
4 people authored Nov 29, 2023
1 parent 91ad69f commit f18b4cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions samcli/commands/deploy/deploy_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,9 @@ def deploy(
click.echo(str(ex))
except deploy_exceptions.DeployFailedError:
# Failed to deploy, check for DELETE action otherwise skip
if self.on_failure != FailureMode.DELETE:
raise

self.deployer.rollback_delete_stack(stack_name)
if self.on_failure == FailureMode.DELETE:
self.deployer.rollback_delete_stack(stack_name)
raise

else:
try:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/commands/deploy/test_deploy_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def test_on_failure_delete_rollback_stack(self, mock_client, mock_session):

self.deploy_command_context.on_failure = FailureMode.DELETE

self.deploy_command_context.run()
with self.assertRaises(DeployFailedError):
self.deploy_command_context.run()

self.assertEqual(self.deploy_command_context.deployer.rollback_delete_stack.call_count, 1)

Expand Down

0 comments on commit f18b4cc

Please sign in to comment.