The Amazon Web Services Serverless Application Model is an open-source framework that benefits you and helps in building serverless applications on AWS freely and easily.
A serverless application is an amalgamation of the following things, Lambda functions, event sources, and many other resources that work together to perform specific tasks.
Be sure such serverless applications are much more than just only a Lambda function; it includes more additional resources such as APIs, databases, and event source mappings.
AWS SAM is used to define your serverless applications.
AWS SAM consists of the following components:
AWS SAM template specification:-
We use this specification to define our serverless application. It delivers you a sincere and obvious syntax describing the functions, API, permissions, configurations, and events to make up a serverless application. You can use an AWS SAM template file to operate on a single, deployable, versioned unit that's your serverless application.
AWS SAM command-line interface (AWS SAM CLI):-
We use this tool to prepare serverless applications that AWS SAM templates have defined. The CLI provides you
Installing the AWS SAM CLI on Linux
The AWS Serverless application model CLI is supported on 64-bit OS versions of recent distributions of Fedora, CentOS, Ubuntu, and Amazon Linux 2. To install the AWS SAM CLI, you first have to extract or "unzip" the downloaded package. If your OS doesn't have the built-in unzip command, users will have to use an alternate.
To install and configure the prerequisites to use the AWS SAM CLI on the Linux host, you will have to follow these steps:
Step 1: Create an AWS account
Proceed by creating an AWS account.
Step 2: Configure IAM and AWS credentials
The IAM user, used with AWS SAM, must have all of the required permissions to make the necessary AWS service calls and manage AWS resources. The easiest way to ensure that a user has sufficient permissions is to grant the administrator privileges.
Step 3: Install Docker (optional)
We use the Docker application to run containers on Linux machines. AWS SAM provides a local environment similar to AWS Lambda to use as a Docker container. You can use this container for building, testing, and debugging serverless applications.
To run functions and serverless projects locally with the AWS SAM CLI, one must have Docker installed and working. The AWS SAM CLI utilizes the DOCKER_HOST environment variable to make contact with the Docker.
Docker is available on so many different operating systems, including most modern Linux distributions, for example, CentOS, Debian, and Ubuntu.
Follow these steps to install the Docker, using Amazon Linux 2 :
sudo yum update -y
sudo amazon-Linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Log out and Log in simultaneously to pick up the new docker group permission.
One must close your current SSH terminal window now and reconnect to your instance in a new one.
Your new SSH session should have all the appropriate docker group permissions.
Step 4: Install the AWS SAM CLI
Following are the steps mentioned to install the AWS SAM CLI:
The output should exactly look like the following piece of the example given below:
<64-character SHA256 hash value> AWS-sam-CLI-Linux-x86_64.zip
4. Now, Unzip the installation files into the sam-installation/ subdirectory.
unzip AWS-sam-CLI-Linux-x86_64.zip -d sam-installation
Install the AWS SAM CLI using this command.
On successful installation, it should look like the following:
SAM CLI, version 1.18.0
You're now ready to start your development.