Lets transpile index.ts file and run our test lambda function.
$cd $WORKSPACE/$FUNCTIONNAME$tsc$npmrunsam>function[email protected] sam /Users/oz/src/project-one/function-one> node_modules/aws-sam-local/node_modules/.bin/sam local invoke -e src/event.json function-one2019/09/1818:16:23Successfullyparsedtemplate.yaml2019/09/1818:16:23ConnectedtoDocker1.402019/09/1818:16:23Fetchinglambci/lambda:nodejs8.10imagefornodejs8.10runtime...nodejs8.10:Pullingfromlambci/lambdaDigest:sha256:bc59e063662af0e2ad2a634e0ca23e10a31ea1db12212da80aebf2ff2d9ee323Status:Imageisuptodateforlambci/lambda:nodejs8.102019/09/1818:16:24Invokingdist/index.handler (nodejs8.10)2019/09/1818:16:24Mounting/Users/oz/src/project-one/function-oneas/var/task:roinsideruntimecontainerSTARTRequestId:8f64aa70-8928-1bd4-8f5c-df84051ab7b3Version: $LATEST2019-09-18T22:16:25.501Z8f64aa70-8928-1bd4-8f5c-df84051ab7b3value1=value12019-09-18T22:16:25.501Z8f64aa70-8928-1bd4-8f5c-df84051ab7b3value2=value22019-09-18T22:16:25.501Z8f64aa70-8928-1bd4-8f5c-df84051ab7b3value3=value32019-09-18T22:16:25.501Z8f64aa70-8928-1bd4-8f5c-df84051ab7b3DEVENDRequestId:8f64aa70-8928-1bd4-8f5c-df84051ab7b3REPORTRequestId:8f64aa70-8928-1bd4-8f5c-df84051ab7b3Duration:8.67msBilledDuration:100msMemorySize:128MBMaxMemoryUsed:30MB"{\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.