DOP-C02 Question 140
Select 2Your organization has implemented an AWS CodePipeline to automate the deployment of a web application. The pipeline includes a source stage connected to a CodeCommit repository, a build stage using CodeBuild, and a deployment stage using AWS CodeDeploy. Recently, a deployment failed due to an issue with an outdated configuration file. You want to ensure that future deployments always use the latest configuration files stored in an S3 bucket. How should you modify the pipeline to achieve this?
- A
Add an additional source stage in CodePipeline that points to the S3 bucket and triggers the pipeline on object changes.
- B
Use an AWS Lambda function to copy the latest configuration files from the S3 bucket to the CodeBuild environment during the build stage.
- C
Update the CodeBuild buildspec file to download the configuration files from the S3 bucket as part of the build process.
- D
Integrate the S3 bucket with AWS CodeDeploy to automatically fetch the configuration files during the deployment stage.
- E
Create an EventBridge rule to trigger the pipeline when a new object is uploaded to the S3 bucket.
Show answer and explanation
Correct answers: B, C
Explanation
The correct approach is to ensure the latest configuration files are incorporated into the pipeline during the build stage. Using an AWS Lambda function or updating the buildspec file to download the files directly from the S3 bucket achieves this efficiently and aligns with automation best practices. Adding a new source stage or triggering the pipeline via EventBridge can complicate the pipeline unnecessarily, and CodeDeploy does not support direct integration with S3 for this purpose.
- A. Incorrect.
Adding a separate source stage for the S3 bucket could work, but it would require significant restructuring of the pipeline. Additionally, this approach is less efficient as it may cause unnecessary pipeline executions.
- B. Correct.
Using an AWS Lambda function to copy the configuration files ensures that the latest files are always available during the build stage. This is a valid approach as it integrates seamlessly with CodeBuild.
- C. Correct.
Updating the buildspec file to download the configuration files directly from the S3 bucket is an efficient solution and aligns with best practices for managing dependencies during the build stage.
- D. Incorrect.
CodeDeploy does not natively fetch configuration files from an S3 bucket during deployments. You would need to manually integrate this functionality, which is not straightforward.
- E. Incorrect.
Triggering the pipeline with an EventBridge rule for S3 events is not ideal, as it may lead to unnecessary pipeline executions and does not directly address how the configuration files are incorporated into the pipeline.