Introduction to SAM
In this section, we will learn about SAM, which will help us build and deploy serverless functions:
- As mentioned earlier, SAM is about writing infrastructure as code. So, this is what a Lambda function would be described as in SAM:
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: < Name of function >: Type: AWS::Serverless::Function Properties: Handler: < index.handler > Runtime: < runtime > CodeUri: < URI of the bucket >
- In this block of code, we enter the details—the name of the function, and the URI of the S3 bucket where our code package is hosted. In the same way that we named the index and the handler in our Lambda settings, we need to enter those details here, too. The
index.handler
is the file in which our function code is located. TheHandler
is the name of the function in which our Lambda logic is written. Also, theRuntime
is user-defined. You...