Tuesday 22 May 2018

What is AWS SAM (Serverless Application Model)?









In this blog post we are going to discuss about Amazon web services serverless application model. Recently Amazon web services has released an open source lambda based serverless infrastructure named as Serverless Application Model (SAM). AWS SAM runtime application model powers it’s lambda functions-as-a-service (FaaS) model.
What is serverless application model?
Serverless application model enables organizations to develop, build and run applications without thinking much about servers. The big advantage of building and running serverless application is, you don’t require to equip and manage servers. With serverless application model, you can build and run any kind of application or services with high availability.
Why we use serverless application model?
Serverless application model reduces the overhead of managing and running servers in the cloud and on-premises. This act enhances developers productivity to focus more on core development areas to deliver a great product. No servers overhead, flexible scaling of applications, and high availability of service are the benefits of the serverless application model.
What is AWS Serverless Application Model?
Have you ever thought of building and running applications without a server? Yes, that’s right with the help of serverless architecture we can build and run the applications and services. The serverless architecture is a revolutionary addition to the cloud computing technology.
AWS is one of the early adopters of serverless architecture and created serverless application model named as AWS SAM. AWS serverless application model is used to create serverless applications. AWS SAM extended from CloudFormation and defines simpler code functions for creating serverless resources and it also supports APIs, Lambda functions, mappings and, DynamoDB database tables.
AWS serverless application uses API Gateway, S3 object storage, and DynamoDB database tables as components. See below for complete list of AWS SAM components.
Architectural Components of AWS SAM
  • API Actions
  • AWS S3 Objects
  • DynamoDB Database Tables
  • CloudWatch Events
  • Amazon Kinesis Objects
  • Amazon SNS Notifications
  • AWS IoT Rules
  • Alexa Events
AWS SAM is based on CloudFormation, AWS SAM uses JSON or YAML to create templates. These templates files are nothing but CloudFormation templates.
In AWS SAM you can include various new resources and property types in the resources section of the template. You can also include other template sections and intrinsic functions of CloudFormation to access properties only at runtime.
In CloudFormation template, you can include objects defined from AWS SAM by creating transform section in the template in the root document with a value of AWS::Serverless-2018-05-07.
Different Resource Types
  • Resource types
  • Event source types
  • Property types
  • Globals Section
Example: AWS SAM Sample Template
AWSTemplateFormatVersion: '2018-02-05'
 
Transform: 'AWS::Serverless-2018-05-07'
 
Resources:
 
 MyFunction:
 
   Type: 'AWS::Serverless::Function'
 
   Properties:
 
     Handler: index.handler
 
     Runtime: nodejs6.10
 
     CodeUri: 's3://my-bucket/function.zip'
All property names in AWS SAM are case sensitive.
Globals Section in AWS SAM Template
In AWS SAM template Globals is a section to create properties common to all the Serverless Function and APIs.
All the AWS::Serverless::Function and AWS::Serverless::Api resources will inherit the properties defined here.
Globals Example:
Globals:
 
 Function:
 
   Runtime: nodejs6.10
 
   Timeout: 180
 
   Handler: index.handler
 
   Environment:
 
     Variables:
 
       TABLE_NAME: data-table
 
 Api:
 
   EndpointConfiguration: REGIONAL
 
   Cors: "'www.example.com'"
 
Resource types
 
AWS::Serverless::Function
 
AWS::Serverless::Api
 
AWS::Serverless::SimpleTable
Benefits of AWS SAM
AWS users already taking advantage of AWS serverless architecture. With AWS SAM, you can develop, test, build and deploy applications without thinking much about infrastructure provisioning.
  • Get rid of server overheads
  • Rapid application development
  • Reduced product development costs
  • Flexible scaling of applications
  • High availability of service
AWS SAM helps you to create, test, build and deploy applications without servers, this will reduce the burden on developers to focus more on application development. Serverless architecture is still in initial stages and its landscape is going to evolve with the ecosystem of tools and processes. We hope that you understood the AWS SAM concept clearly if you have any question on AWS serverless architecture, please leave your comment in the below comment section. We will get back to you as soon as possible.

No comments: