Skip to content

Releases: aws/serverless-application-model

🥁 SAM Implementation is now open source!

04 Apr 17:57
Compare
Choose a tag to compare

Spec + Code == Awesomeness

In 2016, we launched SAM and opened up the SAM specification on this Github repo to invite collaborators. We've loved your questions, proposals for new features, enhancements to examples, bug reports, and passionate discussions around developing serverless applications.

Today, we are incredibly excited (💃🕺🍾 🎉) to open source the underlying SAM implementation - the Python code that converts SAM templates to CloudFormation stacks. Now, in addition to proposing changes to the SAM Spec, you can contribute new features and enhancements to all of SAM! You'll find the code under the samtranslator folder and the tests under the tests directory.

Development Process

We invite anyone who is interested in serverless to participate in developing SAM. You can fork the SAM repository, add new event sources, new resources, or any new features that help you build serverless apps faster.

Once you're ready to merge back in, propose changes and solicit feedback by creating a pull request on GitHub. Also, use the #samdev slack channel to communicate and collaborate with the AWS SAM team and fellow SAM developers.

Releases

We will periodically deploy the code from GitHub through CloudFormation. More on this soon.

Getting Started

Clone the repository and read the Development Guide for more information on how to get setup and use this code. The easiest way to run this code is by running the tests.

#samdev Slack

Come hang out with SAM Team and the community developers on #samdev Slack channel and help us develop SAM.

Click on this link to get invited - https://awssamopensource.splashthat.com (https://awssamopensource.splashthat.com/)

CAUTION: Plenty of passionate Python and Serverless developers hangout in this channel. There will be intense, and sometimes heated, discussions around Python, coding, and improving serverless developer experience. If you are looking for a place to chill, this Slack channel is not for you

CloudWatch Logs Trigger

As a part of this release, we have also added support for CloudWatch Logs Trigger. You can easily trigger a Lambda function when log statements are written to CloudWatch.

  LogsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: .
      Handler: index.handler
      Runtime: nodejs6.10
      Events:
        LogsProcessor:
          # This is your Logs trigger
          Type: CloudWatchLogs
          Properties:
            LogGroupName: !Ref CloudWatchLambdaLogsGroup
            FilterPattern: Hello log processor

What's next?

You! 👈 Yeah, you!

Come join the Slack Channel. Collaborate with us to start hacking SAM together. Let's work together to make it really simple for developers to build serverless applications.

Loads of API features, bug fixes and improvements

12 Mar 23:02
Compare
Choose a tag to compare

This one is a big release! So grab a popcorn 🍿 and start reading:

API Features

CORS, yeah CORS!

You can now add CORS to your SAM apps in one line Cors: "'www.example.com'"! This will allow a webpage at "www.example.com" to call your APIs. As a bonus, SAM will automatically create the correct AllowMethods headers to allow only the methods served on each API Path. If you want, you can override other Cors properties by passing a dictionary. Checkout the Spec for full configuration.

CORS is probably the most talked about issue in this Github repo (39 issues mention CORS). We are thrilled to get this out :)

Learn more in this example

Regional Endpoints

If you want to connect the API to your own CloudFront distribution, or want to use it with Lambda@Edge, or just want to API reduce latency, you can now make your APIs Regional by setting EndpointConfiguration: REGIONAL in your API.

Binary Media Types

Send images, pdf, or any binary data through your APIs by adding the following configuration:

BinaryMediaTypes:
  # API Gateway will convert ~1 to / 
  - image~1png
  - image~1gif

Don't forget to set isBase64Encoded: true in your Lambda function response. Checkout this full example for more details

Logging, Metrics, CacheTTL: Any Stage Settings

To add logging or turn on metrics or set the CacheTTL, you can now do that in the MethodSettings property of your SAM template. The value of this property is directly passed through to CloudFormation. So any feature available in CloudFormation MethodSettings property will be available to you in SAM:

    MethodSettings: [{
        # Turn on Info logging
        "LoggingLevel": "INFO",

        # Enable Metrics
        "MetricsEnabled": True,

        # Trace-level Logging
        "DataTraceEnabled": True,

        # On all Paths & methods
        "ResourcePath": "/*",
        "HttpMethod": "*",
    }]

Refer to resources generated by SAM

SAM will generate an API Gateway Stage and API Gateway Deployment for every AWS::Serverless::Api resource. If you want to refer to these properties in an intrinsic function such as Ref or Fn::GetAtt, you can append .Stage and .Deployment suffix to the API's Logical ID. SAM will convert it to the correct Logical ID of the auto-generated Stage or Deployment resource respectively.

  • !Ref MyApi.Stage => Ref the Stage generated by SAM
  • !Ref MyApi.Deployment => Ref the Deployment resource generated by SAM

This allows you to connect SAM generated resources with other CloudFormation resources. This is super important, especially, if you want to refer to the Deployment resource whose Logical ID keeps changing during every deployment.

Function

Per Function Concurrency

This property allows you to set a concurrency limit to each of your Lambda functions. Use this by adding ReservedConcurrentExecutions property to your Function resource

SimpleTable

TableName, and Tags properties are now available

Bug Fixes

  • Managed policy ARNs, and intrinsic functions for managed policies are now supported.
  • We will throw an error if invalid value for function policies are specified, instead of passing the value to CloudFormation
  • Support Integers in Tags of Serverless::Function
  • BucketEncryption property of S3 resource should work now(#275)

New Regions

SAM is now available in all regions that Lambda is available including AWS GovCloud (US) and AWS China (Beijing) Region. Refer to the Region table for all the regions that Lambda is available in.

Documentation Updates 📖

  • SAM Internals: Take a look under-the-hood of how SAM generates CloudFormation resources and learn about the naming convention used by SAM
  • CloudFormation compatibility - SAM is built on top of CloudFormation, which means you want to be able to use all the cool features CloudFormation offers such as Intrinsic Functions, DependsOn, Conditions etc. SAM's support for CloudFormation features is not 100%. So read this document to understand what works and what does not. If a missing feature is blocking you, then create a Github Issue and let us know!
  • FAQs - We have started collecting common questions and answers into a separate document. Thanks to @sgarcez for starting this!

CONTRIBUTORS NEEDED

We are laying the ground work to create a Sphinx based documentation website for SAM. Documentation from the docs folder will be rendered there in a pretty UI. Check it out - https://awslabs.github.io/serverless-application-model/

As you noticed, this website looks bare and empty. We are still in the process of improving the UI, adding more documentation and surfacing relevant information. Our hope is to make this the Go-To destination for all things SAM.

If you are using SAM, and love it, and want to earn some Karma, help us build this website. It is a simple static website created with Sphinx. You can find the source code the website at ./docs/website. There is a Makefile to get you up and running. We are looking for all sorts of help:

  • Add more docs (#251)
  • Improve README.md to help people get started with SAM easier. Checkout README.md in my fork to get a sense of general direction.
  • Improve website UI - Write a new Sphinx theme and write a neat UI

Start Hacking!

👩‍💻👨‍💻 => 🐿

Make your apps more secure - SAM Policy Templates

30 Nov 18:56
Compare
Choose a tag to compare

Just when you thought we were still in an ice cave in Alaska, here is another amazing SAM feature to make your apps very secure:

Introducing Policy Templates

AWS Managed Policies are a simple mechanism to give your Lambda Function permission to access AWS resources. For example, AmazonDynamoDBFullAccess gives permission to access DynamoDB Tables. More precisely, this will give your function access to all DynamoDB APIs against all
DynamoDB tables in all regions. This is excessively permissive when all that your function does is Read & Write values from one table.

SAM provides a tighter and more secure version of AWS Managed Policies called Policy Templates. This are a set of readily availbale policies that can be scoped to a specific resource in the same region where your stack exists. The following example gives your function CRUD access to just one table defined in your stack,

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      ...
      Policies:

        # Give just CRUD permissions to one table
        - DynamoDBCrudPolicy:
            TableName: !Ref MyTable

      ...

  MyTable:
    Type: AWS::Serverless::SimpleTable

Checkout https://github.com/awslabs/serverless-application-model/blob/master/docs/policy_templates.rst for more information

Lots more to come.. Stay tuned! 📻

Globals, Safe Lambda Deployments, Lambda Versions & Aliases, Local Lambda execution 🐿

29 Nov 01:38
Compare
Choose a tag to compare

What's New?

In the last few months, we moved out of our cozy offices into a ice cave somewhere in Alaska to cut out from the noise and focus on one thing - innovate and deliver some awesome SAM features for you. If this Github page was quiet for a while, this is the reason. To break the silence, here are some amazing features we have just launched:

Safe Lambda Deployments
SAM integrates with AWS CodeDepoy to provide safe, gradual, traffic-shifting deployments for your Lambda functions. You can stop worrying and start pushing code to production with confidence!

MyLambdaFunction:
  Type: AWS::Serverless::Function
  Properties:
     ...
     DeploymentPreference:
       Type: Canary10Percent10Minutes

Read more about Safe Lambda Deployments here

Lambda Versions & Aliases
SAM provides a dead simple way to publish new versions on every code push and use an Alias to point to the latest version. Just add the following property to Serverless::Function resource:

AutoPublishAlias: live

The above property will create a new Alias called live, point all your event sources to the Alias, automatically publish a new Lambda Version every time you push new code, and point the Alias to the latest version. This can be used stand alone but the real power comes when you combine it with DeploymentPreference to do gradual shifting of traffic from your old version to new version, monitoring Alarms, and trigger rollbacks if something goes wrong.

Read more about AutoPublishAlias here

Globals
You can now define all common properties of Serverless Function in one place and let every function inherit it. You can even override some properties or add additional values at the specific function level. The following example enables safe deployments for all your functions and environment variables that are shared with all the functions!

Globals:
  Function:
    Runtime: nodejs6.10
    Timeout: 60
    Environment:
      Variables:    
         DbConnection: mysql://somewhere
     AutoPublishAlias: live
     DeploymentPreference:
       Type: Canary10Percent10Minutes

Resources:
  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Environment:
        Variables:    
          TableName: mytable   

Read more about Globals here

SAM Local CLI
Run Lambda functions locally on your computer by starting with a simple SAM template. This is launched couple of months back but still worth mentioning because it makes your life so much easier.

Installation:

npm install -g aws-sam-local

Checkout https://github.com/awslabs/aws-sam-local for how to use it.

More to come

Actually, this is just a start. We have a lot more features (spoiler alert: API Gateway logging, CORS, more..) coming out real soon

👩‍💻👨‍💻 => 🐿

AWS Serverless Application Model (AWS SAM) Now Supports AWS X-Ray

01 Jun 18:13
Compare
Choose a tag to compare

The AWS Serverless Application Model (AWS SAM) has introduced AWS X-Ray support. You can now configure the X-Ray tracing mode for your Lambda functions within your SAM template. X-Ray helps you analyze and debug distributed applications. With X-Ray, you can identify the root cause of performance issues and errors in your Lambda functions.

Read More here: https://aws.amazon.com/about-aws/whats-new/2017/06/aws-serverless-application-model-aws-sam-now-supports-x-ray/

AWS Serverless Application Model Supports Inline Swagger and AWS CloudFormation Intrinsic Functions