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?
- A. Run sam package and sam deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
- B. Run cdk synth and cdk deploy commands. Create a Lambda test event from the AWS Management Console. Test the Lambda function.
- C. Run cdk synth and sam local invoke commands, specifying the function construct identifier and the path to the synthesized CloudFormation template. ✓
- D. Run cdk synth and sam local start-lambda commands, specifying the function construct identifier and the path to the synthesized CloudFormation template.
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】