DVA-C02 Question 232
Select 3A developer is working on an AWS Lambda function that needs to pull code from a Git-based repository hosted on AWS CodeCommit. The developer wants to implement a CI/CD pipeline for automatic deployment whenever changes are pushed to the repository. Which of the following steps must the developer take to achieve this?
- A
Set up an Amazon EventBridge rule to trigger the pipeline on repository changes.
- B
Configure an AWS CodePipeline pipeline with a source stage connected to the AWS CodeCommit repository.
- C
Manually deploy the Lambda function after every commit to the repository.
- D
Create an IAM role with permissions for AWS CodeCommit and assign it to the Lambda function.
- E
Add a build stage in the pipeline to package the Lambda function code.
Show answer and explanation
Correct answers: A, B, E
Explanation
To implement an automated CI/CD pipeline for a Lambda function using AWS CodeCommit, you must set up an EventBridge rule to trigger the pipeline on repository changes, configure a CodePipeline pipeline with a source stage connected to the repository, and include a build stage to package the Lambda function code. These steps ensure end-to-end automation from code changes to deployment.
- A. Correct.
Correct: Amazon EventBridge (formerly CloudWatch Events) can be used to detect changes in the CodeCommit repository and trigger the CI/CD pipeline.
- B. Correct.
Correct: AWS CodePipeline is designed to automate the CI/CD process. The pipeline needs a source stage connected to the CodeCommit repository to retrieve code changes.
- C. Incorrect.
Incorrect: Manual deployment contradicts the goal of implementing a CI/CD pipeline and is not required in an automated setup.
- D. Incorrect.
Incorrect: While the Lambda function needs appropriate permissions to execute, the IAM role for CodeCommit is irrelevant for triggering or deploying the pipeline.
- E. Correct.
Correct: A build stage is required to package the Lambda function code properly (e.g., zipping files, installing dependencies) before deployment.