AWS Certified Developer – Associate (DVA-C02) — Question 72

A developer is implementing an AWS Cloud Development Kit (AWS CDK) serverless application. The developer will provision several AWS Lambda functions and Amazon API Gateway APIs during AWS CloudFormation stack creation. The developer's workstation has the AWS Serverless Application Model (AWS SAM) and the AWS CDK installed locally.

How can the developer test a specific Lambda function locally?

Answer options

Correct answer: C

Explanation

The correct answer is C because it utilizes the 'sam local invoke' command to test the Lambda function directly, which allows for local testing with specified events. Options A and B involve deploying to the cloud, which does not facilitate local testing. Option D uses 'sam local start-lambda', which is for starting a local Lambda service but does not directly invoke a function for testing.