-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
Describe the bug
I have a Custom Resource in cdk code that calls a Lambda function.
Works fine most of the time. However, if we don't deploy this stack for a longer time we are seeing the following error message during deployment:
"failed to deploy: UPDATE_ROLLBACK_COMPLETE: Received response status [FAILED] from custom resource. Message returned: ERROR: Lambda is initializing your function. It will be ready to invoke shortly."
Seems to me that the lambda is in cold-start mode and a simple internal retry of calling the Lambda would fix the issue. If I rerun the deployment again, it will work.
I also found a Github Action that looks very similar to my error: #20123
But the fix attached to it does not apply to already existing Lambda functions.
I had already a support case open in AWS Support Center and their final advise was to open an issue here.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
The cdk should retry to call the Lambda function until it's ready if this error message comes back.
Current Behavior
Error message:
"failed to deploy: UPDATE_ROLLBACK_COMPLETE: Received response status [FAILED] from custom resource. Message returned: ERROR: Lambda is initializing your function. It will be ready to invoke shortly."
Reproduction Steps
const lambdaTrigger = new AwsCustomResource(construct, 'TriggerExistingLambdaCustomResource', {
timeout: Duration.minutes(5),
policy: AwsCustomResourcePolicy.fromStatements([
new PolicyStatement({
actions: ['lambda:InvokeFunction'],
effect: Effect.ALLOW,
resources: [dbMigrationLambda.functionArn],
}),
]),
onCreate: {
service: 'Lambda',
action: 'invoke',
parameters: {
FunctionName: dbMigrationLambda.functionName,
Payload: JSON.stringify({
'S3Bucket': bucketName,
'DatabaseName': databaseName
}),
},
physicalResourceId: PhysicalResourceId.of('invokeLambdaCreate-call-lambda'),
},
onUpdate: {
service: 'Lambda',
action: 'invoke',
parameters: {
FunctionName: dbMigrationLambda.functionName,
Payload: JSON.stringify({
'S3Bucket': bucketName,
'DatabaseName': databaseName
}),
},
physicalResourceId: PhysicalResourceId.of('invokeLambdaUpdate-call-lambda'),
},
installLatestAwsSdk: false,
});
Possible Solution
Internal retry until the Lambda function is ready if this error message comes back.
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.214.0
AWS CDK CLI version
2.1025.0
Node.js Version
20.19.5
OS
Ubuntu 24.04.3
Language
TypeScript
Language Version
TypeScript 5.8.3
Other information
No response