3.2 - CI/CD and deployment strategies (CodeDeploy, canary)
AWS Certified Developer Associate objective 3.2 covers CI/CD pipelines and deployment strategies. A canary deployment shifts a small percentage of traffic to the new version first, watches metrics, then completes the rollout, limiting blast radius; linear and all-at-once are the other CodeDeploy shift styles. In a CodeDeploy deployment, the appspec.yml file in the application bundle defines the deployment lifecycle hooks and, for EC2/on-premises, which files go where. When a developer wants CodeBuild to run many builds in parallel across configurations, batch builds fan out parallel build groups from one project. You should also know CodePipeline stages, CodeCommit, blue-green with CodeDeploy, and artifacts. Expect scenario questions that describe gradual traffic shifting, defining deployment hooks, or parallel builds, and ask which CI/CD mechanism - canary, appspec.yml or CodeBuild batch builds - is being described.
Shift a small % of traffic first = canary deployment. CodeDeploy lifecycle hooks + file mapping = appspec.yml. Run many builds in parallel across configs = CodeBuild batch builds.
Practice questions
1. Which deployment strategy shifts a small percentage of traffic to the new version first to limit blast radius?
- Canary deployment (correct answer)
- All-at-once deployment
- Recreate deployment
- In-place full swap
A canary deployment routes a small slice of traffic to the new version, monitors it, then shifts the rest if healthy. All-at-once maximizes blast radius on failure.
2. Which framework is a shorthand for CloudFormation that simplifies defining serverless Lambda, API, and DynamoDB resources?
- AWS CDK
- AWS Amplify
- AWS SAM (correct answer)
- AWS OpsWorks
The Serverless Application Model (SAM) is a CloudFormation extension with concise resource types (AWS::Serverless::Function/Api/SimpleTable) and a CLI to build, test locally, and deploy.
3. How can you route a percentage of traffic to a new Lambda version and roll back automatically on errors?
- A weighted alias with CodeDeploy canary and CloudWatch alarms (correct answer)
- A single $LATEST version always deployed in place on each change
- A larger memory allocation on the function
- A DynamoDB global table for the code
A Lambda alias can split traffic by weight between versions; CodeDeploy performs canary/linear shifts and rolls back if a CloudWatch alarm fires, enabling safe deployments.
4. A CodeDeploy deployment to Lambda should shift 10% of traffic, wait 5 minutes, then shift the rest. Which configuration name matches?
- AllAtOnce
- Linear10PercentEvery1Minute
- Canary10Percent5Minutes (correct answer)
- HalfAtATime
Canary10Percent5Minutes shifts 10% first, waits 5 minutes to monitor, then moves the remaining 90% at once. Linear configs move equal increments on an interval instead.
5. A developer wants to test a SAM application's Lambda and API locally before deploying. Which command should they use?
- aws cloudformation deploy
- sam local invoke / sam local start-api (correct answer)
- git push to CodeCommit
- aws lambda update-function-code repeatedly
The SAM CLI runs functions and APIs locally in Docker: sam local invoke tests a single function, and sam local start-api emulates API Gateway, enabling fast local iteration before sam deploy.
6. In a CodeDeploy deployment, which file defines the lifecycle hooks and, for EC2, where to copy files?
- buildspec.yml at the repository root
- appspec.yml in the application bundle (correct answer)
- template.yaml transformed by SAM
- Dockerfile building the application image
CodeDeploy reads appspec.yml (or .json): for EC2/on-prem it maps files and defines hooks (BeforeInstall, AfterInstall, ApplicationStart, ValidateService); for Lambda/ECS it defines version/traffic hooks.