SAM app with CI/CD pipeline - Runtime version is not supported by this build image

0

I am using this tutorial https://catalog.workshops.aws/complete-aws-sam/en-US. The tutorial recommended python 3.7 but as that version has reached end of life I tried to use python 3.12. After setting up the CI/CD stuff in code pipeline, When I push to get it fails in code pipeline with the error that says "Runtime version is not supported by this build image". I have specified the runtime version as 3.12 in all the build spec files so not sure what I need to do. The message says the image only supports 3.7, 3.8 and 3.9. And when I choose those versions everything works. My question is, since python 3.12 is officially supported for lambdas, why is this happening? Am I missing something?

asked 25 days ago121 views
1 Answer
3

Hello.

I think the cause of the error is probably that the image used by CodeBuild is outdated.

Please try setting as below when editing codepipeline.yaml.
https://catalog.workshops.aws/complete-aws-sam/en-US/module-4-cicd/module-4-cicd-codepipeline/70-unittests

It may be improved if you change the "Image" part to build Lambda's Python.
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html#lambda-compute-images

# Uncomment and modify the following step for running the unit-tests
CodeBuildProjectUnitTest:
  Type: AWS::CodeBuild::Project
  Properties:
    Artifacts:
      Type: CODEPIPELINE
    Environment:
      Type: LINUX_CONTAINER
      ComputeType: BUILD_GENERAL1_SMALL
      Image: aws/codebuild/amazonlinux-x86_64-lambda-standard:python3.12
    ServiceRole: !GetAtt CodeBuildServiceRole.Arn
    Source:
      Type: CODEPIPELINE
      BuildSpec: pipeline/buildspec_unit_test.yml

profile picture
EXPERT
answered 25 days ago
  • Thanks so much Riku for your prompt answer, I tried it but it failed with the different error so I am going to start from scratch to make sure I do this cleanly and try your suggestion again. By the way the current line in CodePipeline yaml was Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0 I am going to change this to Image: aws/codebuild/amazonlinux-x86_64-lambda-standard:python3.12 By the way, I would like to ask you one more question please. I am thinking of using the arm processors by saying sam init --architecture arm64 If I did that, should I still use the same image for the code pipeline you suggested or should I use a different image

  • For arm64, I think you need to use the image below.

    aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.12
    
  • Thanks so much Riku, Unfortunately it failed again when did the following step sam deploy -t codepipeline.yaml --stack-name sam-app-pipeline --capabilities=CAPABILITY_IAM

    The error was image aws/codebuild/amazonlinux-aarch64-lambda- standard:python3.12 is not supported for projects with environment type LINUX_CONTAINER and compute type BUILD_GENERAL1_SMALL (Service: AWSCodeBuild; Status Code: 400; Error Code: InvalidInputException; Request ID: 52acc56c- 2672-4653-b7f2- 81a8ca8004cb; Proxy: null)

  • If so, try using the image below.

    aws/codebuild/amazonlinux2-aarch64-standard:3.0
    
  • Thanks so much again Riku, I really appreciate your help. I tried this but when I did sam deploy -t codepipeline.yaml --stack-name mytest-app-pipeline --capabilities=CAPABILITY_IAM this time I am getting the error below

    Error: Failed to create changeset for the stack: mytest-app-pipeline, An error occurred (ValidationError) when calling the CreateChangeSet operation: Stack:arn:aws:cloudformation:eu-west-1:429340948226:stack/mytest-app-pipeline/459802a0-c1dc-11ee-b505-06f224412593 is in ROLLBACK_COMPLETE state and can not be updated.

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.

Guidelines for Answering Questions