Lesson 1 of 5 CI/CD and Testing for ML and AI

Configuring AWS Developer Tools for MLOps

This lesson explains how CodeBuild, CodeCommit, CodeDeploy, CodePipeline and CodeConnections, which the exam guide names, automate building, testing and deploying ML code, containers, pipelines and models.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the role of each developer tool.
  • Separate model build and model deploy pipelines.
  • Troubleshoot common MLOps pipeline failures.

The services

AWS CodeCommit hosts private Git repositories; after a period closed to new customers, it returned to general availability in November 2025. AWS CodeConnections (formerly CodeStar Connections) connects pipelines to GitHub, GitLab and Bitbucket repositories. AWS CodeBuild runs build and test commands defined in buildspec.yml in managed containers: unit tests, linting, Docker image builds, CloudFormation packaging and calls that upsert and start SageMaker pipelines. AWS CodeDeploy deploys application code to EC2, ECS and Lambda with blue/green and canary strategies. AWS CodePipeline chains source, build, test, manual approval and deploy stages.

# buildspec.yml for a model-build repository
version: 0.2
phases:
  install:
    runtime-versions: {python: 3.12}
    commands: [pip install -r requirements.txt]
  build:
    commands:
      - pytest tests/unit
      - python pipelines/run_pipeline.py --upsert --start --role-arn $SAGEMAKER_ROLE
artifacts:
  files: [pipeline-definition.json]
Match the pairs

Developer tools

Exam skills 3.3.2

Match each AWS developer tool with its role in an MLOps pipeline.

Log in to try this activity Interactive activities are free with an account.

MLOps pipeline structure

A common MLOps setup, provided by SageMaker Projects templates, separates building models from deploying them with two pipelines. The model build pipeline runs when training code changes: AWS CodeBuild tests the code, then creates or updates and starts the SageMaker pipeline, which trains, evaluates and registers a new model version.

The model deploy pipeline runs when a model version is approved, detected through an EventBridge event, or when deployment code changes. It deploys to a staging environment with AWS CloudFormation, runs tests, waits for a manual approval and then deploys to production. Separating the two lets data scientists iterate on models while deployment follows a controlled process.

The following diagram shows the build and deploy pipelines.

The two pipelines of a SageMaker Projects MLOps setup. The model build pipeline runs when training code changes: CodeBuild tests the code and starts the SageMaker pipeline, which registers a new version. The model deploy pipeline runs when a version is approved: it deploys to staging, runs tests, waits for manual approval and deploys to production.
SageMaker Projects templates provide this structure.

Troubleshooting

MLOps pipelines fail in characteristic ways: a CodeBuild step lacks permission to start the SageMaker pipeline or pass its role, an approved model version does not trigger deployment because the EventBridge rule does not match, or a deployment to staging fails because the endpoint configuration references a missing image. The pipeline's execution history and the CloudWatch logs of each step usually show which. The following table lists common failures and fixes.

SymptomLikely cause and fix
CodeBuild cannot run docker buildEnable privileged mode on the project
CodeBuild AccessDenied on ECR push or SageMaker callsAdd permissions to the CodeBuild service role (and iam:PassRole for SageMaker roles)
Pipeline source from GitHub never triggersConnection still Pending; complete the handshake in the console
Build cannot reach private resourcesConfigure the CodeBuild project with VPC settings
Artifacts cannot be decrypted in another accountKMS key policy must allow the other account's roles
Build logs missingCheck CloudWatch Logs configuration and role permissions

The following diagram matches two errors in the image build stage of a CI/CD pipeline to their fixes.

The two failures in the image build stage and their fixes. Cannot connect to the Docker daemon means the CodeBuild project lacks privileged mode; AccessDenied on ecr:PutImage means the CodeBuild service role lacks the ECR push permissions.
The scenario is illustrative.
Troubleshooting scenario

A failing pipeline

Exam skills 3.3.2

Fix the CI/CD pipeline problems one at a time.

Log in to try this activity Interactive activities are free with an account.
Worked example

A failing image build

A CodePipeline stage that builds an inference image fails with "Cannot connect to the Docker daemon", and after that is fixed, with AccessDenied on ecr:PutImage.

The first error means the CodeBuild project lacks privileged mode, which Docker builds require. The second means the CodeBuild service role lacks ECR push permissions for the repository. Enabling privileged mode and adding ecr:InitiateLayerUpload, ecr:UploadLayerPart, ecr:CompleteLayerUpload, ecr:PutImage and ecr:GetAuthorizationToken fixes the stage.

Check yourself

How does CodePipeline use a GitHub, GitLab or Bitbucket repository as its source?

Show answer

Through an AWS CodeConnections connection.

Exam Tips

Remember for the exam

  • GitHub, GitLab or Bitbucket source for CodePipeline: CodeConnections.
  • CodeCommit is available to new customers again.
  • Docker builds in CodeBuild need privileged mode.
  • Model build and model deploy are usually separate pipelines.
  • Approval of a model version can trigger the deploy pipeline through EventBridge.