Skip keypair delete when lack permissions #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Keypairs do not form any dependencies with other AWS resources nor do they cost anything, so they can be deleted or left behind without consequence.
The only reason to delete them is to keep the list of keypairs clean.
This is a noble goal but if the user we are given doesnt allow deletion then its better to just give up on deleting rather than fail.
But we should also avoid attempting to delete every throwaway keypair otherwise as more keypairs are created it will take longer and longer to run.
So this PR implements logic to give up on keypair deletion when we hit an
UnauthorizedOperation
error.An alternative to this is to have keypair deletion as a config in the AwsBuilder but I would rather reduce the cognitive load of yet another config option.