1 Answer
- Newest
- Most votes
- Most comments
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
Relevant content
- asked 6 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 7 months 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.
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.
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.