DVA-C02 exam dumps

DVA-C02 practice question 286 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 286

Single answer

You are developing a serverless application using AWS Lambda functions. The code for the application is managed in a private Git repository hosted on AWS CodeCommit. You want to automate deployments of your Lambda function every time there is a new commit to the main branch in the repository. Which approach should you take to achieve this?

  1. A

    Configure an Amazon EventBridge rule to trigger the Lambda function directly whenever a commit is pushed to the main branch.

  2. B

    Set up an AWS CodePipeline with a source stage connected to the CodeCommit repository and a deploy stage that deploys the updated code to the Lambda function.

  3. C

    Use a Git post-commit hook on your local machine to invoke the Lambda function and update its code whenever a commit is pushed to the main branch.

  4. D

    Manually upload the updated code to the Lambda function each time a commit is made to the main branch in the repository.

Show answer and explanation

Correct answer: B

Explanation

The best approach to automate Lambda function deployments based on changes in a CodeCommit repository is to use AWS CodePipeline. CodePipeline integrates seamlessly with CodeCommit for source control and can include a deployment stage to automatically update the Lambda function with the latest code. This ensures a reliable and automated CI/CD process, adhering to AWS best practices.

  • A. Incorrect.

    Amazon EventBridge does not have a direct integration to trigger Lambda functions based on commits to a CodeCommit repository. EventBridge rules are typically used for event-driven architectures and not for automating Lambda deployments from CodeCommit.

  • B. Correct.

    This is the correct answer. AWS CodePipeline allows you to create a fully automated CI/CD pipeline. By configuring a source stage with CodeCommit and a deploy stage for the Lambda function, you can automate deployments whenever there is a new commit to the main branch.

  • C. Incorrect.

    A Git post-commit hook on a local machine is not a reliable or scalable solution for automating deployments in a distributed team or production environment. This approach also goes against AWS best practices.

  • D. Incorrect.

    Manually uploading code to the Lambda function is not an automated solution and does not align with modern CI/CD practices or AWS recommendations.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam