CI/CD on AWS
CI/CD pipelines automate build, test and release so code ships safely and often. The exam leans on three services working together: CodeCommit (or GitHub) for source, CodeBuild for build/test, CodeDeploy for release, all orchestrated by CodePipeline.
CodePipeline basics
- A pipeline is made of stages, and stages contain actions (source, build, test, deploy, approval).
- Stages run sequentially; actions within a stage can run in parallel.
- Add a Manual Approval action to pause a pipeline until a human approves - useful before a production deploy.
- Pipeline changes trigger automatically on a source change (via CloudWatch Events/EventBridge for CodeCommit, or webhooks for GitHub) - it is event-driven, not purely polling by default.
- Artifacts pass between stages via an S3 bucket - CodePipeline needs an S3 artifact store.
CodeBuild
- Defined by a buildspec.yml with phases: install, pre_build, build, post_build.
- Runs in managed, ephemeral containers - you pay per build minute, no servers to manage.
- Can output build artifacts and logs to CloudWatch Logs.
CodeDeploy deployment types
- EC2/On-Premises: uses an AppSpec file (appspec.yml) with hooks like BeforeInstall, ApplicationStop, AfterInstall, ApplicationStart, ValidateService.
- Lambda: deployment configs control traffic shifting - Canary (small % first, then rest after a wait), Linear (steady % increases at intervals), All-at-once.
- ECS: supports Blue/Green deployments via CodeDeploy, shifting traffic between task sets using an ALB.
- CodeDeploy can auto-rollback on CloudWatch alarm breach or deployment failure.
Elastic Beanstalk
- PaaS: upload code (or a Docker image), Beanstalk provisions EC2, ASG, ELB, and RDS (optional) for you - you don't manage the underlying resources directly.
- Deployment policies: All at once (fastest, downtime), Rolling (batches, reduced capacity), Rolling with additional batch (no capacity loss, launches extra batch first), Immutable (new ASG entirely, safest, slowest, easy rollback), Traffic Splitting (canary-style, % of traffic to new version).
- Configuration lives in .ebextensions/*.config files (YAML/JSON) inside your app bundle, applied in alphabetical order.
- Environments: separate Web Server (fronts an ALB) vs Worker (polls an SQS queue) environment tiers.
- Beanstalk is NOT for zero-downtime by default with All-at-once - pick Immutable or Traffic Splitting when zero downtime matters.
Common exam traps
- CodeDeploy needs an IAM service role AND an appspec.yml at the root of the deployment bundle - a missing appspec.yml fails deployment.
- Blue/Green on EC2 needs an ASG and ELB; on Lambda it's really traffic shifting between versions/aliases, not separate EC2 fleets.
- Beanstalk swap environment URLs (CNAME swap) gives a near-zero-downtime blue/green style cutover between two full environments.
What are the four phases of a CodeBuild buildspec.yml?
install, pre_build, build, post_build
tap to reveal
Which file does CodeDeploy require for EC2/On-Premises deployments, and where must it sit?
appspec.yml, at the root of the deployment bundle
tap to reveal
Name the five hooks available in an EC2 CodeDeploy appspec.yml lifecycle.
BeforeInstall, ApplicationStop, AfterInstall, ApplicationStart, ValidateService
tap to reveal
What are the three Lambda CodeDeploy traffic-shifting deployment types?
Canary, Linear, All-at-once
tap to reveal
List the five Elastic Beanstalk deployment policies.
All at once, Rolling, Rolling with additional batch, Immutable, Traffic Splitting
tap to reveal
Which Elastic Beanstalk deployment policy is safest and easiest to roll back, but slowest?
Immutable - it launches a whole new ASG before switching traffic
tap to reveal
What does CodePipeline need to pass artifacts between stages?
An S3 bucket configured as the artifact store
tap to reveal
How do you pause a CodePipeline pipeline for human sign-off before deploying to production?
Add a Manual Approval action to a stage
tap to reveal
What triggers a CodePipeline run when CodeCommit is the source?
An EventBridge/CloudWatch Events rule on the repository change (event-driven, not just polling)
tap to reveal
In what order are .ebextensions config files applied in Elastic Beanstalk?
Alphabetical order, from the root of the application bundle
tap to reveal
What are the two Elastic Beanstalk environment tiers and what fronts each?
Web Server tier (fronted by an ALB) and Worker tier (polls an SQS queue)
tap to reveal
How does Elastic Beanstalk achieve a near-zero-downtime blue/green cutover?
By swapping CNAMEs between two separate, fully deployed environments
tap to reveal
What triggers an automatic CodeDeploy rollback?
A CloudWatch alarm breach or a deployment failure
tap to reveal
On ECS, how does CodeDeploy perform Blue/Green deployments?
It shifts ALB traffic between two ECS task sets
tap to reveal