Open CLarge-EZAC opened 3 years ago
There are a few options to consider. In short, we need both AWS CDK and SAM CLI.
https://stackoverflow.com/questions/64689865/debugging-lambda-locally-using-cdk-not-sam
cdk synth --no-staging > template.yaml
sam local invoke MyFunction12345678 --no-event
Official documentation for this option here: https://docs.aws.amazon.com/cdk/latest/guide/sam.html
Alternatively, there is a public beta that blends CDK with SAM. It seems to be a convenience wrapper that calls cdk synth
and figures out the generated function number automatically.
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-cdk-testing.html
sam-beta-cdk local invoke HelloCdkStack/MyFunction
For now, I will work on the sam-beta-cdk
in the hopes it is simpler and therefore resilient to mistakes in execution. But the long-term goal is to run these tests on Github Actions for our CI pipeline. If this beta doesn't work with the CI pipeline, we'll try a different option.
I hit an error; SAM won't locally host a lambda function that references S3, which is a deal breaker. See #11 for details.
Going forward, maybe the original Textract demo has CI testing details that will help.
We need a method to locally debug our lambda python before deploying to AWS. The SAM CLI has some tools to invoke Lambda Functions locally.