AWS · Containers & CI/CD

CodePipeline

CodePipeline automates your release process: every change flows through source, build, test and deploy stages.

Intermediate 5 min Lesson 21 of 30
0/30 in AWS
On this page · 5 min · Intermediate

Learning objectives#

  • Explain pipeline stages and actions
  • Connect GitHub with CodeConnections
  • Add a manual approval
  • Deploy to ECS from a pipeline

Explanation#

A pipeline has stages (Source, Build, Deploy) made of actions. Artifacts pass from one stage to the next through an S3 bucket.

GitHub sources use a connection (AWS CodeConnections), approved once in the console.

Build actions usually run CodeBuild; deploy actions can target ECS, Elastic Beanstalk, CloudFormation, S3 or CodeDeploy.

Manual approval actions pause the pipeline until someone approves — useful before production.

Code example: A container release pipeline#

TextA container release pipeline Illustrative
Stage 1  Source     GitHub (via CodeConnections), branch main
            │  source artifact
Stage 2  Build      CodeBuild: test → docker build → push to ECR → write imagedefinitions.json
            │  build artifact
Stage 3  Staging    ECS deploy action → service shop-api-staging
Stage 4  Approve    Manual approval (notify team via SNS)
Stage 5  Production ECS deploy action → service shop-api-prod
Expected output
A merge to main reaches staging automatically and production after one click of approval.

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. The source stage triggers on pushes to main.
  2. CodeBuild runs tests and produces imagedefinitions.json (container name + image URI).
  3. The ECS deploy action updates the service with the new image.
  4. The approval gate protects production.

Real-world use case#

An AWS-native team keeps everything — source connection, builds, deploys and approvals — inside their AWS account with CloudTrail auditing.

Common mistakes#

No tests in the build stage

A pipeline without tests just ships bugs faster.

Broad pipeline role permissions

Scope the pipeline and CodeBuild roles to the resources they deploy.

Best practices#

  • Test in the build stage
  • Deploy to staging before production
  • Use manual approval for production
  • Define pipelines as code (CloudFormation or CDK)

Remember this#

Source → Build → Deploy (+ Approve).

imagedefinitions.json tells ECS which image to run.

Staging first, then approve, then prod.

Practice exercise#

Your task: What file must the build stage output for the standard ECS deploy action?

Show solution
JSON Illustrative
[ { "name": "api", "imageUri": "123456789012.dkr.ecr.ap-south-1.amazonaws.com/shop-api:3f2a9c1" } ]
// saved as imagedefinitions.json

Mini quiz#

CodePipeline quizMultiple choice Question 1 of 1

Which action pauses a pipeline until a person approves?

Score so far: 0/0

Want more? Practise all AWS MCQs · AWS interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.