github aws/aws-sam-cli v0.3.0
SAM CLI Refresh 🎉: `sam init`, Better validation, Tons of bug fixes, and 🐍

latest releases: v1.78.0.dev202303230901, v1.77.0.dev202303220901, v1.77.0...
4 years ago

What's new in 🐿?

This release is an important milestone - New command to get started with SAM apps, full fidelity SAM Template validation, tons of bug fixes, and greatly improved stability. Oh did I mention, we rewrote the entire CLI from the ground up?! Yes, in 🐍. With this refresh, SAM CLI uses the recently open sourced transform, enabling you leverage any new SAM functionality immediately after release.


New Command: sam init

sam init is a new command that lets you quickly get started with a SAM app in any runtime of your choice. Just install the CLI and type sam init to create a new "Hello World" SAM app that includes everything (directory structure, tests, SAM template, instructions) you need to get started with serverless and eventually grow into a production scale application.

The cool part is, you can use custom templates to initialize a SAM app. For example, you could create a boilerplate SAM app specific for your organization and publish to a private GitHub repo. Others in your organization can run sam init --location gh:your-org/your-repo to initialize an app. Applications initialized using sam init can be customized to use a different project name, Lambda runtime or even include/exclude various functionalities. Check out the sam init documentation for more information.

Full Fidelity SAM Validation

SAM CLI now provides full-fidelity validation of SAM templates because it uses the recently open-sourced SAM implementation. A template that passes sam validate command locally will pass the validation when deployed through AWS CloudFormation.


If you didn't already notice, we have started calling this tool "SAM CLI" instead of "SAM Local CLI". This is a non-functional change we are making to better align the tool with its purpose - simplify the process of creating, deploying and maintaining serverless apps using the command line.

Installation Instructions

We now support a PIP-based installation method. To install the new SAM CLI, use the following

# Uninstall the old CLI if you had originally installed
npm uninstall -g aws-sam-local

# Install the new CLI through PIP
pip install --user aws-sam-cli

Go → Python

With this release, we have rewritten SAM CLI in Python to use the open-sourced AWS SAM implementation. As a user, you should notice no difference but as a contributor to the CLI, you would have to adjust your development workflow. We have a detailed DEVELOPMENT_GUIDE.rst to help you quickly ramp up. Read the DESIGN.rst for more details on design rationale and decisions.

Changes to CloudFormation intrinsic functions support

There are two notable changes regarding how intrinsic functions are handled within the CLI:

  1. If you use an Inline Swagger definition (in DefinitionBody property) property and use Fn::Join to construct the Lambda Integration ARN in the x-amazon-apigateway-integration section, you would have to convert this to Fn::Sub to work with SAM CLI as of this release. You can easily convert Fn::Join to Fn::Sub without any loss of functionality. For example:
A Fn::Join usage like this:
"Fn::Join": ["", ["arn:aws:apigateway:", {"Ref": "AWS::Region"}, ":lambda:path/2015-03-31/functions/", {"Fn::GetAtt": ["MyFunction", "Arn"]}, "/invocations"]]

Can be converted to:
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations"
  1. If you use CloudFormation parameters with default values to reference a Lambda Function's Timeout or Runtime properties, you now need to specify the values of these in the template. If you are using template parameters to standardize the value of Runtime or Timeout across all your functions, you use Globals to specify the value once and have it applied to all your functions.
    Default: nodejs6.10

  Type: AWS::Serverless::Function
    Runtime: !Ref NodeRuntime

You can convert it to:
    # All your functions will get nodejs6.10 runtime
    Runtime: nodejs6.10

  Type: AWS::Serverless::Function

Bug Fixes

  • Full fidelity SAM template validation #342
  • Globals support #234 and #226
  • Value of APIGW Path property on proxy response is now correct #244
  • NPM Installation issues #263
  • Empty values in Api Event are 'null' instead of empty map/lists #338 and #340
  • Content-Type of application/json is always added to headers #329 and #325 and #361
  • Full featured YAML support for parsing complex intrinsic functions like !Ref, !GetAtt without failing in template parsing - #342
  • Parity with credential resolutions mechanisms supported by AWS CLI since SAM CLI now uses boto3 #372
  • Better support for ANY method #289
  • Encode JSON output from generate-event #214
  • Works with Chalice out-of-box #141 (comment)
  • Compatibility with API Gateway Binary Media Types implementation #312
  • Relative paths in CodeUri get resolved with respect to template path #279 #170
  • Make multiple invokes in parallel #301 (comment)
  • Support AWS::Include to inline a Swagger file

Don't miss a new aws-sam-cli release

NewReleases is sending notifications on new releases.