The AWS Serverless Application Model (AWS SAM) is a toolkit that improves the developer experience of building and running serverless applications on AWS. AWS SAM consists of two primary parts:
SAM Transformation
AWS SAM does the complex work of transforming your template into the code necessary to provision your infrastructure through AWS CloudFormation.
This is an example of a basic serverless application using SAM.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
GetProductsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.example.GetProductsFunction::handleRequest
Runtime: java17
Architectures:
- arm64
MemorySize: 1024
Policies:
- DynamoDBReadPolicy:
TableName: !Ref ProductTable
Events:
GetProductsEvent:
Type: Api
Properties:
Path: /products
Method: get
ProductTable:
Type: AWS::Serverless::SimpleTable
The following diagram provides an overview of the transformation with SAM.
sam build
builds the application based on the chosen runtime and configuration within the
template..aws-sam/build
folder with the built artifacts (for example, class files or
jars).Follow this blog to learn more about Building serverless Java application with the AWS SAM CLI.