AWS Magic
develop
develop
  • Welcome
  • Lambda
    • Local Lambda Development
      • Prerequisites
      • Starter Kit or Manual?
      • Use Starter Kit
      • Manual Configuration
        • Environment Variables
        • Python Setup
        • Node Setup
        • Source & Config Files
        • Test The Configuration
      • Run Lambda in VSCode
      • Debug Lambda in VSCode
      • Deploy Lambda Function
    • Lambda & API GW
  • TypeScript
    • Promises
Powered by GitBook
On this page

Was this helpful?

  1. Lambda
  2. Local Lambda Development
  3. Manual Configuration

Test The Configuration

Lets transpile index.ts file and run our test lambda function.

$ cd $WORKSPACE/$FUNCTIONNAME
$ tsc
$ npm run sam

> function-one@1.0.0 sam /Users/oz/src/project-one/function-one
> node_modules/aws-sam-local/node_modules/.bin/sam local invoke -e src/event.json function-one

2019/09/18 18:16:23 Successfully parsed template.yaml
2019/09/18 18:16:23 Connected to Docker 1.40
2019/09/18 18:16:23 Fetching lambci/lambda:nodejs8.10 image for nodejs8.10 runtime...
nodejs8.10: Pulling from lambci/lambda
Digest: sha256:bc59e063662af0e2ad2a634e0ca23e10a31ea1db12212da80aebf2ff2d9ee323
Status: Image is up to date for lambci/lambda:nodejs8.10
2019/09/18 18:16:24 Invoking dist/index.handler (nodejs8.10)
2019/09/18 18:16:24 Mounting /Users/oz/src/project-one/function-one as /var/task:ro inside runtime container
START RequestId: 8f64aa70-8928-1bd4-8f5c-df84051ab7b3 Version: $LATEST
2019-09-18T22:16:25.501Z    8f64aa70-8928-1bd4-8f5c-df84051ab7b3    value1 = value1
2019-09-18T22:16:25.501Z    8f64aa70-8928-1bd4-8f5c-df84051ab7b3    value2 = value2
2019-09-18T22:16:25.501Z    8f64aa70-8928-1bd4-8f5c-df84051ab7b3    value3 = value3
2019-09-18T22:16:25.501Z    8f64aa70-8928-1bd4-8f5c-df84051ab7b3    DEV
END RequestId: 8f64aa70-8928-1bd4-8f5c-df84051ab7b3
REPORT RequestId: 8f64aa70-8928-1bd4-8f5c-df84051ab7b3    Duration: 8.67 ms    Billed Duration: 100 ms    Memory Size: 128 MB    Max Memory Used: 30 MB    

"{\n  \"key1\": \"value1\",\n  \"key2\": \"value2\",\n  \"key3\": \"value3\"\n}"

With this line sam local invoke -e src/event.json function-one, we invoked function-one.ts and passed the event.json file as the event payload. SAM Local ran the lambda function in a local container using docker. We can see the max memory used, duration as we would see during a real lambda execution.

PreviousSource & Config FilesNextRun Lambda in VSCode

Last updated 5 years ago

Was this helpful?