/CI/CD — CodePipeline, CodeBuild, CodeDeploy
Concept Detail

CI/CD — CodePipeline, CodeBuild, CodeDeploy

Difficulty: hard

Overview


CodePipeline: Managed CI/CD orchestration. Stages: Source → Build → Test → Deploy. Manual Approval Action pauses pipeline and notifies via SNS. Artifacts stored in S3 between stages.

CodeBuild: Managed build service. Reads buildspec.yml. Phases: install → pre_build → build → post_build. VPC access for private resources. Local build with CodeBuild agent.

CodeDeploy — EC2/On-Premises:

StrategyDowntimeNotes
AllAtOnceYesFastest
HalfAtATimeNo50% capacity
OneAtATimeNoSlowest
Blue/GreenNoNew fleet, shift traffic

CodeDeploy — Lambda:

  • Linear: Equal % increments (e.g., Linear10PercentEvery1Minute).
  • Canary: Small % first, then all (e.g., Canary10Percent5Minutes).
  • AllAtOnce: Immediate.

appspec.yml: Defines deployment configuration and lifecycle hooks (BeforeInstall, AfterInstall, ApplicationStart, ValidateService).

CodeDeploy Rollback: Automatic on alarm/failure (redeploys previous version as a new deployment).

CodeArtifact: Managed artifact repo for npm, PyPI, Maven, NuGet.

Deployment Strategies Summary: Canary and Linear support automatic rollback via CloudWatch Alarms.

Practice Linked Questions


easy

Q1. A development team uses AWS CodePipeline. After a code push to CodeCommit, the pipeline triggers CodeBuild. CodeBuild compiles the code but the unit tests fail. What happens to the pipeline?


Select one answer before revealing.

medium

Q2. A developer wants to run unit tests and integration tests in parallel during a CodePipeline Build stage to reduce total build time. Which CodeBuild feature supports running multiple build groups in parallel?


Select one answer before revealing.

medium

Q3. A team uses AWS CodeDeploy to deploy to EC2 instances. They want to gradually shift traffic from the old version to the new version — starting with 10% and shifting 100% after 10 minutes if no alarms trigger. Which deployment configuration should be used?


Select one answer before revealing.

easy

Q4. A developer writes a buildspec.yml for CodeBuild. The build has 4 phases. Which of the following represents the correct order of phases in a CodeBuild build?


Select one answer before revealing.

easy

Q5. A developer uses AWS SAM to define a Lambda function and API Gateway. After running `sam deploy`, the developer needs to test the Lambda function locally before the next deployment. Which command should be used?


Select one answer before revealing.

medium

Q6. A developer needs to create a CodePipeline that builds a Docker image, pushes it to ECR, and updates an ECS service. The pipeline must pass the ECR image URI from the Build stage to the Deploy stage. How is data passed between CodePipeline stages?


Select one answer before revealing.

medium

Q7. A team wants to enforce a manual approval before production deployments in their CodePipeline. A Slack notification must be sent to the ops team when approval is required. Which CodePipeline action type should be added?


Select one answer before revealing.

hard

Q8. A developer uses CodeDeploy to deploy a new version of a Lambda function. They want to automatically roll back if the p99 latency CloudWatch alarm triggers within 10 minutes of deployment. Which CodeDeploy feature enables this?


Select one answer before revealing.

medium

Q9. A developer uses AWS CloudFormation to deploy infrastructure. After updating a stack, the deployment fails. CloudFormation shows ROLLBACK_IN_PROGRESS. What does this mean and what is the developer's next step?


Select one answer before revealing.