CodeBuild with the Amazon Linux 2 environment

By Michael Anckaert - published on - posted in DevOps - tagged with AWS CICD Build Automation Linux

If you're using AWS CodeBuild to build your software, there's a gotcha if you're using the new Amazon Linux 2 environment. If you use your old buildspec.yml you will run into an error

Phase context status code: YAML_FILE_ERROR Message: This build image requires selecting at least one runtime version.

Previous versions of CodeBuild had a different environment configuration that allowed you to select an environment image like python:3.6.6. This environment specified your runtime. But the new CodeBuild version makes you select either Amazon Linux 2 or Ubuntu as environment. Note that this doesn't specify the runtime, just the base operating system your build will be using. Specifying the runtime now happens in your buildspec.yml file:

version: 0.2

            python: 3.7
            - echo "building stuff..."

Your existing CodeBuild projects will not be affected, they will continue to work. But any new projects you create will require you to specify the new environment, and specify the runtime in your buildspec.yml file.

More information about the runtime-versions parameter can be found here: