serverless-components / express

⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
https://serverless.com/components
Apache License 2.0
375 stars 34 forks source link

Wait for the Lambda state to return to Successful #76

Closed rrooding closed 1 year ago

rrooding commented 2 years ago

Amazon is rolling out Lambda states now, see: https://aws.amazon.com/blogs/compute/coming-soon-expansion-of-aws-lambda-states-to-all-functions/

This was interfering with our deployments, as the provisioning takes some time and because of that, the updateLambdaCode that is called immediately after updateLambdaConfiguration was constantly giving the following error:

ResourceConflictException: The operation cannot be performed at this time. An update is in progress for resource: arn:aws:lambda:eu-west-1:xxx:function:api-xxx-function.

The state change can take up to a minute: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#updateFunctionConfiguration-property

This PR adds a polling check between the two updates to wait for the Lambda state to return to Successful before continuing.