CodePipeline, CodeBuild & CodeDeploy

AWS's native CI/CD trio: orchestrate stages, run builds, and roll out deploys.

AWS offers a native CI/CD suite that stays entirely inside your account.

The three services

  • CodePipeline — the orchestrator. Defines stages (source, build, deploy) and moves the artifact through them.
  • CodeBuild — the build engine. Runs your buildspec.yml in a managed container to compile, test, and package.
  • CodeDeploy — the release engine. Rolls new versions out to EC2, ECS, or Lambda with rolling or blue-green strategies.

A typical pipeline: CodePipeline watches your repo, hands each commit to CodeBuild, then CodeDeploy releases the built artifact. Everything is IAM-controlled and needs no external CI service.

Example

Example · json
{
  "pipeline": {
    "name": "myapp-prod",
    "stages": [
      { "name": "Source",
        "actions": [{ "actionTypeId": { "category": "Source", "provider": "CodeStarSourceConnection" } }] },
      { "name": "Build",
        "actions": [{ "actionTypeId": { "category": "Build", "provider": "CodeBuild" } }] },
      { "name": "Deploy",
        "actions": [{ "actionTypeId": { "category": "Deploy", "provider": "ECS" } }] }
    ]
  }
}

When to use it

  • A team uses CodePipeline to orchestrate source-from-CodeCommit, build-with-CodeBuild, and deploy-with-CodeDeploy as an all-AWS CI/CD chain.
  • An engineer uses CodeDeploy with an EC2 deployment group to roll out a new application version across a fleet of servers.
  • A company triggers a CodePipeline run automatically when a new Docker image is pushed to ECR so the pipeline always deploys the latest build.

More examples

Create a CodePipeline pipeline

Creates a pipeline from a JSON definition file that declares stages for Source, Build, and Deploy.

Example · bash
aws codepipeline create-pipeline \
  --pipeline file://pipeline.json

CodePipeline pipeline definition

Shows the Source stage definition using a CodeStar connection to pull from GitHub on every push to main.

Example · json
{
  "name": "my-app-pipeline",
  "roleArn": "arn:aws:iam::123456789012:role/CodePipelineRole",
  "artifactStore": { "type": "S3", "location": "my-pipeline-bucket" },
  "stages": [
    {
      "name": "Source",
      "actions": [{
        "name": "Source",
        "actionTypeId": { "category": "Source", "owner": "AWS", "provider": "CodeStarSourceConnection", "version": "1" },
        "configuration": { "ConnectionArn": "arn:aws:codestar-connections:...", "FullRepositoryId": "myorg/myapp", "BranchName": "main" },
        "outputArtifacts": [{ "name": "SourceOutput" }]
      }]
    }
  ]
}

Manually release a pipeline change

Triggers a pipeline run manually, useful for re-running after fixing a configuration issue without waiting for a commit.

Example · bash
aws codepipeline start-pipeline-execution \
  --name my-app-pipeline

Discussion

  • Be the first to comment on this lesson.
CodePipeline, CodeBuild & CodeDeploy — AWS Deployment | SoundsCode