AWS
DevOps
  • knowledge
    • glossary
    • network knowledge
      • CIDR Block
      • OSI
      • List of Ports
      • Network model
    • AWS best practices
      • Least privilege principle
      • Support Plan
      • Well-architected framework
        • Well-architected framework
        • Cost optimization
        • Operational Excellence
        • Performance efficiency
        • Reliability
        • Security
    • Exams
      • DOP-C02
        • DOP-C02 topics
        • DOP-C02 Labs
      • DVA-C02
      • SOA-C02
  • services
    • access management
      • Directory Service
      • IAM
        • PassRole
      • IAM Identity Center (SSO)
      • Organizations
        • Organizational Unit
        • Control Tower
      • AD Domain Service
    • analytics
      • data analytic
        • Athena
        • QuickSight
        • Redshift
      • data collection
        • Data Lake
        • Lake Formation
      • data processing
        • EMR
        • Kinesis
        • Glue
          • Glue Data Catalog
      • OpenSearch
    • compute
      • Batch
      • EC2
        • Auto Scaling
        • AMI
        • ELB
          • Global accelerator
        • Security Group
        • EBS
        • EC2 Instance Store
        • Spot Fleet
      • Elastic Beanstalk
      • Lambda
        • Layer
        • Lambda API
      • Outposts
      • Wavelength
      • SAM
      • VMWare Cloud
    • container
      • Copilot
      • ECR
      • ECS
        • ECS Anywhere
      • EKS
        • EKS Anywhere
        • EKS Distro
      • Fargate
    • cost management
      • Budgets
      • Cost Explorer
      • Saving Plans
      • Compute Optimizer
    • database
      • Data Engineer
      • Document DB
      • DynamoDB
        • DynamoDB API
        • Scan
      • ElastiCache
      • Keyspaces
      • MemoryDB for Redis
      • Neptune
      • Quantum Ledger Database
      • RDS
        • Aurora
          • Aurora Global Database
          • Aurora Serverless
      • Timestream
    • devTools
      • CICD
        • CodeArtifact
        • CodeCommit
        • CodeBuild
        • CodeDeploy
        • CodePipeline
      • CloudFormation
      • CodeGuru
      • CodeStar
      • CodeWhisperer
      • X-Ray
      • Deployment strategies
    • finance
      • Cost explorer
    • integration
      • AppFlow
      • AppSync
      • EventBridge
      • MQ
      • SNS
      • SQS
      • Step Functions
      • SWF
    • management
      • AppConfig
      • AWS Backup
      • AWS CDK
      • Config
      • Grafana
      • Health Dashboard
      • Proton
      • Service Catalog
      • System Manager
      • SSM
      • Resource Group
      • OpsWorks (discontinued)
    • media
      • Elemental MediaConvert
      • Transcoder
    • messaging
      • SES
    • migration
      • Application Migration Service
      • DataSync
      • DMS
      • Migration Evaluator
      • Migration Hub
      • Server Migration Service
      • Snow Family
      • Transfer Family
    • ML
      • Comprehend
      • Forecast
      • Kendra
      • Lex
      • Rekognition
      • SageMaker
        • SageMaker Data Wrangler
        • SageMaker ML Lineage Tracking
    • monitoring
      • CloudTrail
      • CloudWatch
      • TrustedAdvisor
    • networking
      • CloudFront
      • Customer gateway
      • Edge Location
      • hybrid networking
        • Direct Connect
          • Direct Connect Gateway
        • Site-to-site VPN
      • PrivateLink
      • Region
        • AZ
      • Route 53
      • Transit Gateway
      • VPC
        • VPC Lattice
        • Subnet
          • NACL
        • Internet Gateway
        • Network Firewall
        • VPN
        • NAT Gateway
      • Virtual Private Gateway
    • security
      • Artifact
      • ACM
      • CloudHSM
      • Cognito
      • Detective
      • Firewall Manager
      • GuardDuty
      • Inspector
      • KMS
      • Macie
      • Network Firewall
      • Resource Access Manager
      • Security Hub
      • Secret Manager
      • Secret Hub
      • Shield
      • STS
      • Trusted Advisor
      • WAF
    • storage
      • Backup
      • EBS
      • EFS
      • FSx
      • S3
        • S3 Glacier
        • S3 Snippet
        • S3 Mountpoint
      • Snow family
      • Storage gateway
      • WorkDocs
    • web & mobile
      • Amplify
      • API Gateway
      • Device Farm
      • Pinpoint
Powered by GitBook
On this page
  • Overview
  • Features
  • SAM template
  • SAM CLI
  • Trivia
  1. services
  2. compute

SAM

Serverless Application Model: extension of CloudFormation

PreviousWavelengthNextVMWare Cloud

Last updated 1 year ago

|

Overview

  • A tool kit for building and running serverless applications, contains 2 parts:

  • Can use for deploy serverless application: run locally, package, or deploy to the cloud.

  • Benefits:

    • Construct serverless applications in fewer lines of code.

    • The development time is significantly reduced.

Features

SAM template

  • SAM will translate this CloudFormation syntax to CloudFormation stack that create Lambda and API Gateway, Dynamo table.

  • SAM template has Transform: ‘AWS::Serverless-2016–10–31’ line in the template.

SAM resources can be written alongside the native CloudFormation resources. You can also use intrinsic functions and pseudo parameters in a SAM template just like you would in a native CloudFormation template.

SAM CLI

Initialization

  • sam init: initialize the project

Build & Deploy

  • sam package: packages your AWS SAM application source code, dependencies and resources into a deployment package (.zip file). The .zip file is then uploaded to the S3 bucket that you specify. After that, it returns a copy of your AWS SAM template, replacing references to local artifacts with the Amazon S3 location where the artifacts are uploaded.

  • sam build: build app to .aws-sam directory.

  • sam deploy: will call sam package internally, so don't need to call it seperately.

Here, we use the sam deploy --guided command to deploy our application through an interactive flow. The AWS SAM CLI guides us through configuring our application's deployment settings, transforms our template into AWS CloudFormation, and deploys to AWS CloudFormation to create our resources.

  • sam pipeline init --bootstrap: to configure a CI/CD deployment pipeline for our application.

  • cdk synth: it reads your CDK app code and generates an CloudFormation template.

SAM is built-in with CodeDeploy to help ensure safe Lambda deployments.

Testing

  • sam local invoke: perform local debugging and test.

  • sam local start-api: starts a local instance of API Gateway to test HTTP endpoints.

  • sam remote invoke: to test a deployed Lambda function in the cloud.

Monitor & troubleshooting

  • sam list: to view our deployed resources.

  • sam logs: to view our functions' logs.

Sync to cloud

  • sam sync --watch: to have the AWS SAM CLI watch for local changes. This command is typically used for quick syncing of local changes to AWS and is more suitable for rapid development testing.

Trivia

  • SAM template has Transform: ‘AWS::Serverless-2016–10–31’ line in the template.

Docs
SAM template
SAM CLI