ytausch / serverless-discord-bot

A serverless Discord Bot template built for AWS Lambda based on Discord's slash commands and the slash-create library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateCommandsInvoker update hangs when stack is in state UPDATE_ROLLBACK_COMPLETE

FilipeAleixo opened this issue · comments

I've noticed that sam deploy hangs in this specific situation:

I do an unsuccessful deploy which has to be rolled back due to an error, which then puts the stack in state UPDATE_ROLLBACK_COMPLETE.

When I subsequently correct the error and call sam deploy again it hangs in this stage:

image

This is what I see in the stack:

image

Even deleting the stack becomes impossible after this because there's no way to stop the custom resource (at least I didn't find one), so I just have to wait for it to time out and delete it.

Any clue on how to fix this?

Just pinging you to show what I've built using your repo: https://github.com/EsteFilipe/discord-ethereum-authentication

Thanks for the clean code :)

As far as I understand, this error occurs when a bug is introduced into CreateCommandsFunction that prevents CfnLambda to run as intended and post the custom resource status back to CloudFormation via a pre-signed URL that is provided to the Lambda function. (For more details of how CloudFormation custom resources work under the hood, refer to here).

As long as the CloudFormation resource update is running, it's not possible to update or delete the stack.

Unfortunately, the timeout period for custom resource status updates is quite long (2 hours?) and as far as I can tell, there is currently no way to change this.

The only options I see are:

  1. Wait for the custom resource to timeout and create another stack for development in the meantime
  2. Try to send the status update via HTTP yourself (link) - note: I didn't try this myself

I agree that this is very annoying during development but I do not see any way how to make things easier here. This would be AWS`s turn. If you find out something new with regeard to this issue or if it works out well to send the expected status update yourself - feel free to share!

By the way: Your project looks awesome! Thanks for sharing!

Thanks for the thorough explanation!

The only way I've found to overcome this for development was to just keep creating stacks with new names, while leaving the failed ones so that they time out and I delete them later. This seems like quite a shortcoming from Cloudformation - they even have videos like this one suggesting a hack of send a signal to the lambda in order to be able to delete it https://www.youtube.com/watch?v=hlJkMoCxR-I

commented

Just FYI, I was having problems with CreateCommandsInvoker hanging and was able to fix by increasing the Cloudformation timeout which defaults to 3 seconds.

Also, I've upgraded to Node 18 and didn't find any issues.

Thank you for this repo!