DVA-C02 Question 285
Single answerYou are working on an AWS Lambda function that is part of a serverless application. Your team uses Git as the version control system, and the application is deployed using AWS CodePipeline and AWS CodeDeploy. One of your teammates accidentally pushed an untested commit directly to the main branch, triggering a deployment that caused the Lambda function to malfunction. How can you prevent this from happening in the future while still using Git for version control and AWS CodePipeline for deployment?
- A
Enable branch protections on the main branch in your Git repository and require pull request approvals before merging.
- B
Disable the integration between AWS CodePipeline and your Git repository entirely.
- C
Switch to a different version control tool that does not allow direct commits to the main branch.
- D
Configure AWS CodePipeline to halt deployments if the commit message does not include a specific keyword.
Show answer and explanation
Correct answer: A
Explanation
The best approach to prevent untested code from triggering deployments is to enforce branch protection rules in your Git repository. These rules ensure that code changes to the main branch go through a formal review process, such as requiring pull requests and approvals. This aligns with best practices for CI/CD pipelines and allows teams to maintain the reliability and stability of their applications.
- A. Correct.
This is the correct option. Enabling branch protections and requiring pull request approvals ensures that all changes to the main branch are reviewed and tested before being merged, reducing the risk of untested code triggering deployments.
- B. Incorrect.
Disabling the integration between AWS CodePipeline and the Git repository would prevent any automated deployments, which defeats the purpose of continuous integration and delivery (CI/CD).
- C. Incorrect.
Switching to a different version control tool is unnecessary and does not address the root issue. Git itself provides robust solutions like branch protections to enforce best practices.
- D. Incorrect.
Configuring AWS CodePipeline to halt deployments based on commit message content is not a practical solution. It does not ensure code quality or testing and relies on developers remembering to include specific keywords.