Skip to content

Getting an error when deploying a stack using cdk deploy The stack named mvp700-ServiceModuleStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Lambda function mvp70

0

I'm encountering a deployment failure when attempting to redeploy a Lambda function built using a Docker image. The error occurs during the UPDATE_ROLLBACK_COMPLETE phase with the following message:

The stack named mvp700-ServiceModuleStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Lambda function mvp700-ServiceModuleStack-FacilitiesFilterSortFetc-ufslENgmoYOy reached terminal FAILED state due to InvalidImage(ImageLayerFailure: UnsupportedImageLayerDetected - Layer Digest <sha#>) and failed to stabilize" (RequestToken: 1e4d8b06-7bb3-8b7f-ce6f-081b90d47271, HandlerErrorCode: NotStabilized)

I've recently taken over the backend codebase from a former team member who is no longer with the company. My background is primarily in frontend development, and I’m currently trying to update and redeploy a Lambda function defined in CDK using a Docker image. Troubleshooting Steps Already Attempted:

Set the platform explicitly in CDK with platform: Platform.LINUX_AMD64.

Enabled Docker Buildx (docker buildx create --use) for cross-platform builds on Windows.

  • Cleared the CDK output folder and Docker cache: * rd /s /q cdk.out * docker builder prune -a
  • Verified the Dockerfile uses a Lambda-compatible base image and architecture.
  • Commented out the Docker-based function, deployed successfully, re-enabled it, and then retried the deployment — the error reappeared.
  • Re-authenticated Docker with ECR using aws ecr get-login-password and verified ECR permissions.
  • Verified the Docker Desktop version supports Buildx and multi-platform builds.
1 Answer
0

The error you're encountering indicates that your Lambda function deployment is failing due to an incompatible Docker image layer. This "ImageLayerFailure: UnsupportedImageLayerDetected" error typically occurs when there's an architecture mismatch between your Docker image and AWS Lambda's execution environment.

Here are some steps to resolve this issue:

  1. Ensure proper architecture compatibility: AWS Lambda functions using container images must be compatible with the Lambda execution environment. Make sure your Docker image is built for the x86_64/amd64 architecture, which is what Lambda primarily supports.

  2. Check your Dockerfile: Verify that your base image is Lambda-compatible. AWS provides official Lambda base images that you should use as your starting point, such as amazon/aws-lambda-nodejs for Node.js functions.

  3. Use multi-architecture builds correctly: When using Docker Buildx for multi-platform builds, ensure you're specifying the correct platform flags:

docker buildx build --platform linux/amd64 -t your-image-name .
  1. Inspect the CDK deployment process: The CDK might be overriding your Docker build settings. Check your CDK code to ensure it's not changing the architecture settings during deployment.

  2. Try manual image deployment: As a troubleshooting step, try building and pushing the Docker image manually to ECR, then update your Lambda function to use this image. This can help isolate whether the issue is with the image build process or the CDK deployment.

  3. Check for stack dependencies: Sometimes when a stack deployment fails, there might be resources in a "stuck" state. You might need to manually delete the failed Lambda function from the AWS console before attempting redeployment.

  4. Review CloudFormation events: Check the CloudFormation events for the stack to get more detailed error information, which might provide additional clues about the specific layer that's causing the problem.

If the stack is in a ROLLBACK_COMPLETE state, you might need to delete it manually from the AWS console before attempting to redeploy it, as CloudFormation won't allow updates to a stack in this state.
Sources
Deploying stack through AWS CDK failed with the Error: Stack deploy failed (the stack disappeared while we were deploying it) | AWS re:Post
Regarding deploying the stack using AWS CDK | AWS re:Post
Deploying Stack throws error at CreateKeysAndCertificate | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.