DVA-C02 exam dumps

DVA-C02 practice question 249 of 399

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

DVA-C02 Question 249

Single answer

You are developing a serverless application using AWS Lambda and API Gateway. To perform integration testing, you need to validate the interaction between your Lambda function and an external HTTP API. However, the external API is not yet available, so you decide to use mock endpoints for the testing. Which approach should you use to achieve this?

  1. A

    Use AWS API Gateway's Mock Integration feature to create a mock response for the external API.

  2. B

    Deploy the Lambda function with a hard-coded mock response to simulate the external API.

  3. C

    Use AWS CloudFormation to provision a temporary mock server for the external API.

  4. D

    Use AWS X-Ray to mock the external API's responses during integration testing.

Show answer and explanation

Correct answer: A

Explanation

The AWS API Gateway Mock Integration feature is designed specifically for creating mock responses, which makes it an ideal choice for simulating external API interactions during integration testing. This approach ensures that your Lambda function can be tested without requiring the actual external API to be available, and it doesn’t involve modifying the function's code or provisioning unnecessary infrastructure.

  • A. Correct.

    Correct. AWS API Gateway's Mock Integration feature allows you to define mock responses for an endpoint, making it suitable for simulating the external API's behavior during integration testing.

  • B. Incorrect.

    Incorrect. Hard-coding a mock response in the Lambda function is not recommended because it requires modifying the function's code, making it less reusable and harder to maintain.

  • C. Incorrect.

    Incorrect. AWS CloudFormation is an infrastructure-as-code tool and doesn’t provide native features to create temporary mock servers. It’s not suitable for this use case.

  • D. Incorrect.

    Incorrect. AWS X-Ray is used for tracing and debugging distributed applications but does not have the capability to mock API responses.

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