‫So now let's talk about
‫the local capabilities of the SAM framework.
‫So by using the SAM framework,
‫you can actually locally start AWS Lambda.
‫So if you do SAM local start-Lambda,
‫you will have your Lambda function available
‫as a local endpoint on your computer
‫with an emulation of the Lambda framework.
‫The beautiful thing about it is
‫that now you can start to run automated tests
‫against these local endpoints.
‫You can also locally invoke a Lambda function.
‫For this, you do SAM local invoke
‫and this will actually invoke Lambda function
‫with a payload.
‫So you will do it once
‫and then quit after the invocation is complete.
‫It's very helpful to generate test cases
‫and in case your Lambda function is interacting with AWS
‫because, for example, you're doing a API call to DynamoDB
‫to fetch whatever, re whatever thing from it,
‫then, of course, you must start your local function
‫or invocate with the correct --profile option
‫because you need to say against which environment
‫you want to be running against.
‫You can also start a local API Gateway Endpoint.
‫For this you do SAM local start-API
‫and it's going to start a local HTTP server
‫that will host all your APIs and all your functions.
‫And if somehow you update your code
‫for your Lambda function,
‫automatically the functions are going to be reloaded
‫and your API will be updated.
‫Finally, you can generate events for Lambda functions
‫using the SAM local generate-event function.
‫And to do so, for example, you could combine it with,
‫"Hey, I want to generate an event for Amazon S3
‫for putting in a bucket at a specific key,"
‫and then we pipe that input
‫into the SAM local invoke command that we saw before.
‫So you can generate sample payloads for event sources.
‫It could be whatever source really is a source of Lambda.
‫So Amazon S3, API Gateway, SNS, Kinesis, DynamoDB,
‫and pretty much all of them.
‫Okay, so we've seen the local capabilities
‫of using the SAM framework.
‫I hope you liked it.
‫And I will see you in the next lecture.