Q67 — AWS DVA-C02 Ch.1

Question 67 of 100 | ← Chapter 1

A developer is implementing an AWS Cloud Development Kit (AWS CDK) serverless application. During AWS CloudFormation stack creation, the developer provisions an AWS Lambda function and an Amazon API Gateway API. The developer works locally using both AWS Serverless Application Model (AWS SAM) and AWS CDK. How can the developer locally test a specific Lambda function?

Correct Answer: C. Run cdk synth and sam local invoke commands, specifying the function construct identifier and the path to the synthesized CloudFormation template.

Explanation

Option C correctly describes the process for locally testing a specific Lambda function in a CDK-based project: cdk synth generates the CloudFormation template, and sam local invoke invokes the targeted Lambda function using its construct ID and the template path. Options A and B use deployment commands unsuitable for local testing. Option D uses sam local start-lambda, which starts a local Lambda runtime endpoint—not ideal for single-function invocation. 【Lantern Certification: swufelp1999】