AWS Cloud Developer Associate Certification

15.SAM (Server-less Application Model)

Index

  1. Introduction
  2. SAM-Recipe
  3. CLI Debugging
  4. Policy template
  5. SAM and Code deploy
  6. Exam Summary
  7. SAR(Server-less Application Repository)

Introduction

  1. Framework for developing and deploying serverless applications
  2. All the configuration is YAML code
  3. Generate complex CloudFormation from simple SAM YAML file
  4. Supports anything from CloudFormation: Outputs, Mappings, Parameters, Resources…
  5. Only two commands to deploy to AWS
  6. SAM can use CodeDeploy to deploy Lambda functions
  7. SAM can help you to run Lambda, API Gateway, DynamoDB locally


SAM-Recipe

  1. Transform Header indicates it’s SAM template:
    1. Transform: ‘AWS::Serverless-2016-10-31’
  2. Write Code
    1. AWS::Serverless::Function
    2. AWS::Serverless::Api
    3. AWS::Serverless::SimpleTable
  3. Package & Deploy
    1. aws cloudformation package / sam package
    2. aws cloudformation deploy / sam deploy


CLI Debugging

  1. Locally build, test, and debug your serverless applications that are defined using AWS SAM templates
  2. Provides a lambda-like execution environment locally
  3. SAM CLI + AWS Toolkits => step-through and debug your code
  4. Supported IDEs: AWS Cloud9, Visual Studio Code, JetBrains, PyCharm, IntelliJ, …
  5. AWS Toolkits: IDE plugins which allows you to build, test, debug, deploy, and invoke Lambda functions built using AWS SAM


Policy template

  1. List of templates to apply permissions to your Lambda Functions
  2. Important examples:
    1. S3ReadPolicy: Gives read only permissions to objects in S3
    2. SQSPollerPolicy: Allows to poll an SQS queue
    3. DynamoDBCrudPolicy: CRUD = create read update delete


SAM and Code deploy

  1. SAM framework natively uses CodeDeploy to update Lambda functions
  2. Traffic Shifting feature
  3. Pre and Post traffic hooks features to validate deployment (before the traffic shift starts and after it ends)
  4. Easy & automated rollback using CloudWatch Alarms


Exam Summary

  1. SAM is built on CloudFormation
  2. SAM requires the Transform and Resources sections
  3. Commands to know
    1. sam build: fetch dependencies and create local deployment artifacts
    2. sam package: package and upload to Amazon S3, generate CF template
    3. sam deploy: deploy to CloudFormation
  4. SAM Policy templates for easy IAM policy definition
  5. SAM is integrated with CodeDeploy to do deploy to Lambda aliases


SAR(Server-less Application Repository)

  1. Managed repository for serverless applications
  2. The applications are packaged using SAM
  3. Build and publish applications that can be re-used by organizations
    1. Can share publicly
    2. Can share with specific AWS accounts
  4. This prevents duplicate work, and just go straight to publishing
  5. Application settings and behaviour can be customized using Environment variables

Published by

Unknown's avatar

sevanand yadav

software engineer working as web developer having specialization in spring MVC with mysql,hibernate

Leave a comment