AWS DevOps CI/CD Pipelines 2 — Questions and Answers
Question 1: A team wants to ensure that AWS CodePipeline only proceeds to the production deployment stage after a manual approval. Which action type should they add between the staging and production stages?
- AWS::CodePipeline::ManualApproval
- Manual action in the Approval category (Correct answer)
- AWS Lambda invoke action
- AWS SNS notification action
Correct answer: Manual action in the Approval category
CodePipeline supports a Manual Approval action type in the Approval category that pauses pipeline execution until a designated reviewer approves or rejects.
Question 2: Which AWS service allows you to define build specifications for AWS CodeBuild using a YAML file stored in the source repository?
- buildspec.yml (Correct answer)
- pipeline.yml
- appspec.yml
- taskdef.yml
Correct answer: buildspec.yml
CodeBuild uses a buildspec.yml file in the root of the source repository to define build commands, environment variables, and artifact settings.
Question 3: In AWS CodeDeploy, what is the purpose of the AppSpec file's 'hooks' section?
- To define environment variables for the deployment
- To specify lifecycle event scripts that run at defined points during deployment (Correct answer)
- To list the files to be copied to target instances
- To configure load balancer health check settings
Correct answer: To specify lifecycle event scripts that run at defined points during deployment
The hooks section in the AppSpec file specifies scripts to run at specific lifecycle events such as BeforeInstall, AfterInstall, ApplicationStart, and ValidateService.
Question 4: A company's CodePipeline execution fails at the Build stage. The pipeline should automatically retry the build after a transient failure. Which approach best achieves this?
- Enable pipeline retry in CodePipeline stage settings
- Use an Amazon EventBridge rule to detect failure events and trigger a pipeline re-execution (Correct answer)
- Configure CodeBuild to automatically restart failed builds
- Set up an AWS Lambda function polling pipeline status every minute
Correct answer: Use an Amazon EventBridge rule to detect failure events and trigger a pipeline re-execution
An EventBridge rule can detect CodePipeline stage failure events and trigger an automatic re-execution via the StartPipelineExecution API.
Question 5: Which CodeBuild environment variable contains the URL of the source repository that triggered the build?
- CODEBUILD_SOURCE_REPO_URL (Correct answer)
- CODEBUILD_SOURCE_VERSION
- CODEBUILD_BUILD_ARN
- CODEBUILD_INITIATOR
Correct answer: CODEBUILD_SOURCE_REPO_URL
CODEBUILD_SOURCE_REPO_URL is the predefined CodeBuild environment variable that holds the URL of the source repository used for the build.
Question 6: A team uses AWS CodePipeline with an S3 source stage. What must be enabled on the S3 bucket for CodePipeline to detect new object versions and trigger automatically?
- S3 Event Notifications to SQS
- S3 Versioning (Correct answer)
- S3 Cross-Region Replication
- S3 Lifecycle Policies
Correct answer: S3 Versioning
CodePipeline requires S3 Versioning to be enabled on the source bucket so it can detect new object versions and trigger pipeline executions.
Question 7: In a CodePipeline with parallel actions within a single stage, when does the stage transition to the next stage?
- When the first action in the stage succeeds
- When the slowest action in the stage completes successfully (Correct answer)
- When any action reaches 50% completion
- When the pipeline owner manually advances the stage
Correct answer: When the slowest action in the stage completes successfully
All parallel actions within a stage must succeed before CodePipeline transitions to the next stage; the stage is gated on the last action to complete.
A team wants to ensure that AWS CodePipeline only proceeds to the production deployment stage after a manual approval.
Which action type should they add between the staging and production stages?