SAP-C02 Question 165
Select 3A company is implementing a CI/CD pipeline for a serverless application that is deployed on AWS Lambda using AWS CodePipeline. The team wants to ensure that every code update is automatically tested and deployed only if all tests pass successfully. Which combination of steps in the pipeline is MOST appropriate to achieve this?
- A
Use AWS CodeCommit as the source stage and configure CodePipeline to trigger on changes to the repository.
- B
Add a CodeBuild stage to run unit tests on the code before deployment.
- C
Configure a manual approval step between the test and deploy stages.
- D
Add a CodeDeploy stage to deploy the updated Lambda function.
- E
Use AWS CloudTrail to monitor changes and trigger the pipeline.
Show answer and explanation
Correct answers: A, B, D
Explanation
To implement a CI/CD pipeline for a serverless application using AWS CodePipeline, you need to define stages that include a source stage (e.g., CodeCommit), a test stage (e.g., CodeBuild for unit tests), and a deployment stage (e.g., CodeDeploy for Lambda). This ensures that any code changes are automatically tested and deployed if the tests pass successfully. Manual approvals and CloudTrail are not necessary components for this specific use case.
- A. Correct.
Correct: Using AWS CodeCommit as the source stage ensures that any commits to the repository automatically trigger the CI/CD pipeline.
- B. Correct.
Correct: Adding a CodeBuild stage to the pipeline allows the execution of unit tests, ensuring that code changes are verified before deployment.
- C. Incorrect.
Incorrect: While a manual approval step can provide additional control, it is not required to achieve automated testing and deployment in a CI/CD pipeline.
- D. Correct.
Correct: A CodeDeploy stage is necessary to deploy the updated Lambda function to the production environment as part of the pipeline.
- E. Incorrect.
Incorrect: AWS CloudTrail is used for auditing and monitoring API activity; it is not a component of the CI/CD pipeline.