Topics

notes R shiny predictedit databricks aws

AWS Serverless Application Model (SAM)

[ notes  aws  ]

Overview

Use a SAM template defined in yaml or json to define the CloudFormation stack for your serverless application. AWS CloudFormation can interpret the SAM definition and deploy the application automatically.

Really, SAM is a CloudFormation template and the SAM-specific sections get interpreted based upon the specified transform AWS::Serverless-2016-10-31.

My Use Case

  1. Write an AWS Lambda Function and store it as a GitHub repo
  2. Set-up AWS Codebuild to hook on the GitHub repo and re-build the deployment package, saving it to S3
  3. Leverage a SAM template to then automatically deploy the package from S3 as a working Lambda

Notes

  • Reference the SAM specs
  • The SAM template can define the resources for Lambda (AWS::Serverless::Function), API Gateway (AWS::Serverless::Api), and DynamoDB (AWS::Serverless::SimpleTable).

Sample SAM Template for Lambda on CloudWatch cron

This example is mostly taken from a Lambda export SAM of an existing function:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: Function for hitting the PredictIt API and stashing result to S3
Resources:
  PredictItDataHarvest:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: data_handler.lambda_data_handler
      Runtime: python3.6
      CodeUri: TODO(nadir.sidi): Set this to the S3 URI of the zip file
      Description: ''
      MemorySize: 128
      Timeout: 3
      Role: TODO(nadir.sidi): Put in the desired IAM role ARN here
      Events:
        Schedule1:
          Type: Schedule
          Properties:
            Schedule: 'cron(5,35 * * * ? *)'

TODO

  • Write a SAM template to define the PredictIt data harvest Lambda
  • Review the [AWS Lambda documentation] (https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html) on automated deployment pipelines

Topics

notes

R

shiny

predictedit

databricks

aws

Written on October 2, 2018