aws-actions / aws-cloudformation-github-deploy

Deploys AWS CloudFormation Stacks
MIT License
251 stars 121 forks source link

Unintended exception mishandling after v3 sdk change #136

Closed Zordrak closed 5 months ago

Zordrak commented 6 months ago

https://github.com/aws-actions/aws-cloudformation-github-deploy/commit/6ab7e8a0c3e1c51646b7b6b5ccd3d7712d87ed8c

This commit changes the handling of errors when describing a stack to determine if the stack already exists.

I believe the behaviour of this change is broken and causes unintended consequences.

Previously, if the service threw a StackNotFound exception, then getStack would return undefined to indicate the stack does not exist, and any other service exception would be thrown as an unexpected condition.

Now, any exception thrown by the service is treated as a StackNotFound exception.

As a result the initial describe stack will decide a stack does not exist and will try to create a new one even if the stack does exist, but the API call encountered a generic service exception.

Additionally (and more concerningly), if the service only throws an exception on DescribeStacks, but does not thrown an exception to CreateStack, then the sdk-implemented waiter will wait until its timeout, presuming the stack is CREATE_IN_PROGRESS, ignorant of the exceptions being thrown.

This code needs to discriminate between a StackNotFound and other service exceptions throwable by DescribeStacksCommand

  if (error.$metadata.httpStatusCode === 400 && error.name === "ValidationException") {
Zordrak commented 5 months ago

@kddejong poke on this bugfix 👋 😺

Zordrak commented 5 months ago

Thank you!