A team is seeing more bugs in their Node.js Lambda functions. They want automated tests that closely emulate the Lambda runtime, allow other developers to run tests locally, and run as part of the CI/CD pipeline before AWS CDK deployment. Which solution meets these requirements?
Choose an answer
Tap an option to check your answer.
Correct answer: Install the AWS SAM CLI. Generate sample events with sam local generate-event and create automated test scripts that use sam local invoke to run the Lambda functions locally and validate responses. Document and add the scripts to the CI/CD pipeline..
Why this is the answer
The AWS SAM CLI provides a local testing environment that closely emulates the AWS Lambda runtime, including environment variables and IAM roles, which is crucial for catching bugs related to the Lambda execution context. sam local invoke allows developers to run Lambda functions locally with sample events, and sam local generate-event helps create these events. This approach supports local development, can be integrated into CI/CD pipelines, and is well-suited for Node.js Lambda functions managed by AWS CDK. Using cdk local invoke is not a standard or supported command for local Lambda invocation. Unit testing frameworks simulate the environment but don't fully replicate the Lambda runtime's nuances, potentially missing integration-related bugs. Building a custom Docker container is more complex and less integrated with the AWS ecosystem than using SAM CLI, requiring more effort to maintain and configure for accurate emulation.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed