- Newest
- Most votes
- Most comments
Your CloudFormation stack is stuck in the UPDATE_COMPLETE_CLEANUP_IN_PROGRESS state because it's trying to delete custom resources that were created using AWS Custom Resources in CDK, but the Lambda function that was responsible for handling these custom resources no longer exists.
When CloudFormation tries to delete a custom resource, it sends a delete request to the Lambda function specified in the ServiceToken property of that resource. In your case, the error message indicates that the Lambda function ProdCoreStack-AWS679f53fac002430cb0da5b7982bd22872-1sJMPyCnBfuv cannot be found (404 ResourceNotFoundException).
This situation typically happens when:
- You've refactored your CDK code to use a different approach (as you mentioned, switching to the built-in SSM class)
- The Lambda function that was handling the custom resources was deleted or replaced before CloudFormation could complete the cleanup process
To resolve this issue, you have a few options:
- Recreate the missing Lambda function temporarily:
- Create a Lambda function with the exact same name and ARN that's being referenced
- Implement a simple handler that responds to CloudFormation custom resource requests with SUCCESS
- Once the stack update completes successfully, you can delete this temporary function
- Skip the cleanup phase by manually updating the stack status in CloudFormation:
- This is more advanced and requires AWS CLI commands to modify the stack state
- You would need to mark the stack as UPDATE_COMPLETE instead of UPDATE_COMPLETE_CLEANUP_IN_PROGRESS
- Contact AWS Support:
- If the above options don't work, AWS Support can help manually update the stack state
For the first option, the Lambda function would need to properly handle CloudFormation custom resource requests by sending a SUCCESS response with the appropriate PhysicalResourceId. This would allow CloudFormation to complete the deletion process.
In the future, when refactoring resources that use custom resources, it's best to ensure that the Lambda functions handling those resources remain available until all cleanup operations are complete.
Sources
Update request for CloudFormation custom resources - AWS CloudFormation
AWS::CloudFormation::CustomResource - AWS CloudFormation
aws-cdk-lib.custom_resources module · AWS CDK
AWS::Lambda::Function - AWS CloudFormation
