Skip to content

Bug: When I update my lambda function with a cloudformation template to use a different CPU arch, it doesn't change

0

What I'm trying to do is to deploy one template using SAM and building x64 docker images from my laptop and then modify the SAM / Cloudformation template in a pipeline to build an ARM image and deploy that to the same lambda. What I've seen though is that when I deploy the new SAM template to change the image / cpu architecture, the template shows the correct CPU architecture but the Lambda does not.

1 Answer
0

The issue you're experiencing is not a bug, but rather an expected behavior in AWS CloudFormation and AWS SAM (Serverless Application Model) deployments. When updating Lambda functions, especially when changing attributes like the CPU architecture, CloudFormation optimizes deployments to prevent unnecessary updates and potential disruptions.

In your case, changing the CPU architecture (from x86_64 to arm64 or vice versa) is a significant modification that requires special handling. Here are a few points to consider:

  1. When you're changing the CPU architecture, you need to ensure that your function code, dependencies, and any layers or extensions are compatible with the new architecture. This includes creating a new container image that is built for the target architecture.

  2. CloudFormation may not automatically detect the change in CPU architecture if only the template is modified. You might need to force an update of the Lambda function.

  3. To ensure the change takes effect, you can try the following:

    • Use a different name for your new ARM-based container image in ECR.
    • Update the CodeUri or ImageUri in your SAM template to point to the new image.
    • If using parameters in your template, update a version or timestamp parameter to force a new deployment.
  4. In some cases, you may need to delete the existing Lambda function and recreate it with the new architecture, especially if other update methods don't work.

  5. Verify that your pipeline is correctly building and pushing the ARM-based image to ECR before deploying the updated SAM template.

  6. After deployment, double-check both the CloudFormation stack and the Lambda console to ensure the changes have been applied correctly.

Remember, when migrating between architectures, it's crucial to thoroughly test your function to ensure it performs as expected on the new architecture. If issues persist, you may need to review your deployment pipeline and SAM template to ensure all necessary changes are being made and propagated correctly.

Sources
Lambda Layer not changing when taken from S3 in cf template | AWS re:Post
Selecting and configuring an instruction set architecture for your Lambda function - AWS Lambda
AWS Lambda FUnction | 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.