CodePipeline
CodePipeline automates your release process: every change flows through source, build, test and deploy stages.
On this page · 5 min · Intermediate
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Intermediate
- Updated
- Oct 29, 2026
Related tutorials
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#
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
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#
- The source stage triggers on pushes to main.
- CodeBuild runs tests and produces imagedefinitions.json (container name + image URI).
- The ECS deploy action updates the service with the new image.
- 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#
A pipeline without tests just ships bugs faster.
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
[ { "name": "api", "imageUri": "123456789012.dkr.ecr.ap-south-1.amazonaws.com/shop-api:3f2a9c1" } ]
// saved as imagedefinitions.json
Mini quiz#
Which action pauses a pipeline until a person approves?
Want more? Practise all AWS MCQs · AWS interview questions
My notes#
Saved in this browser.