Skip to content

Exit status 1 if stack is not found in AWS#313

Merged
orien merged 5 commits intomasterfrom
stack-not-found
Mar 13, 2020
Merged

Exit status 1 if stack is not found in AWS#313
orien merged 5 commits intomasterfrom
stack-not-found

Conversation

@orien
Copy link
Copy Markdown
Member

@orien orien commented Mar 12, 2020

As reported in #235 (comment), StackMaster aborts, but with exit status 0 upon not finding the specified stack in AWS. It is expected to report an error via a non-zero exit status.

Update the delete, outputs, and resources commands to exit with a status of 1 if the specified stack does not exist in AWS.

Also the delete command now exits with status 1 if using a disallowed AWS account.

Comment thread lib/stack_master/cli.rb
StackMaster::Commands::Delete.perform(region, stack_name)
StackMaster::Commands::Delete.perform(region, stack_name).success?
end
@kernel.exit false unless success
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stack_master delete is updated to exit with status 1 if the command object is not successful, or a disallowed AWS account is used.

Comment thread features/delete.feature
"""
Account '33333333' is not an allowed account. Allowed accounts are ["11111111"].
"""
And the exit status should be 1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a feature, specifying the behaviour of the delete command when using a disallowed AWS account.


def stack_resources
@stack_resources = cf.describe_stack_resources(stack_name: @stack_definition.stack_name).stack_resources
@stack_resources ||= cf.describe_stack_resources(stack_name: @stack_definition.stack_name).stack_resources
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoising this results in less API calls.

@orien orien force-pushed the stack-not-found branch 2 times, most recently from 6745238 to 3e8c7cf Compare March 12, 2020 22:13
Copy link
Copy Markdown
Contributor

@petervandoros petervandoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! 👍

@orien orien force-pushed the stack-not-found branch from 3e8c7cf to 6da925b Compare March 13, 2020 02:07
@orien
Copy link
Copy Markdown
Member Author

orien commented Mar 13, 2020

☝️ Just rebased against master to resolve the merge conflicts.

@orien orien merged commit 44f36e4 into master Mar 13, 2020
@orien orien deleted the stack-not-found branch March 13, 2020 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants