Skip to main content

AWS SAM Translator is a library that transform SAM templates into AWS CloudFormation templates

Project description

AWS SAM transform

Tests PyPI PyPI - Python Version Contribute with Gitpod

The AWS Serverless Application Model (AWS SAM) transform is a AWS CloudFormation macro that transforms SAM templates into CloudFormation templates.

To use the SAM transform, add AWS::Serverless-2016-10-31 to the Transform section of your CloudFormation template.

Benefits of using the SAM transform include:

  • Built-in best practices and sane defaults.
  • Local testing and debugging with the AWS SAM CLI.
  • Extension of the CloudFormation template syntax.

Getting started

Save the following as template.yaml:

Transform: AWS::Serverless-2016-10-31
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs16.x
      Handler: index.handler
      InlineCode: |
        exports.handler = async (event) => {
          console.log(event);
        }

And deploy it with the SAM CLI:

sam sync --stack-name sam-app

The AWS::Serverless::Function resource will create a AWS Lambda function that logs events it receives.

Under the hood, the template is transformed into the JSON equivalent of the following CloudFormation template:

Resources:
  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      Code:
        ZipFile: |
          exports.handler = async (event) => {
            console.log(event);
          }
      Handler: index.handler
      Role: !GetAtt MyFunctionRole.Arn
      Runtime: nodejs16.x
      Tags:
        - Key: lambda:createdBy
          Value: SAM
  MyFunctionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Action:
              - sts:AssumeRole
            Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Tags:
        - Key: lambda:createdBy
          Value: SAM

For a more thorough introduction, see the this tutorial in the Developer Guide.

Contributing

Setting up development environment

You'll need to have Python 3.7+ installed.

Create a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Set up dependencies:

make init

Run tests:

make pr

See DEVELOPMENT_GUIDE.md for further development instructions, and CONTRIBUTING.md for the contributing guidelines.

Getting help

The best way to interact with the team is through GitHub. You can either create an issue or start a discussion.

You can also join the #samdev channel on Slack.

Learn more

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-sam-translator-1.58.0.tar.gz (306.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aws_sam_translator-1.58.0-py3-none-any.whl (367.9 kB view details)

Uploaded Python 3

aws_sam_translator-1.58.0-py2-none-any.whl (367.9 kB view details)

Uploaded Python 2

File details

Details for the file aws-sam-translator-1.58.0.tar.gz.

File metadata

  • Download URL: aws-sam-translator-1.58.0.tar.gz
  • Upload date:
  • Size: 306.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.13

File hashes

Hashes for aws-sam-translator-1.58.0.tar.gz
Algorithm Hash digest
SHA256 74eff244a4923320e5df2f37617d85505356353e6022ae9812c6f0abcfbad5d3
MD5 7540ff1a6ce0e5479b4340307909c42c
BLAKE2b-256 6233d01190b7f72856a666f06407035b921d9c5951f4e0d8e779d6793bf50c4e

See more details on using hashes here.

File details

Details for the file aws_sam_translator-1.58.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_sam_translator-1.58.0-py3-none-any.whl
Algorithm Hash digest
SHA256 627997303bcfb69209bc752f6b5b28b665b07341cec353d3711b05fc30e21ef8
MD5 a023eae53a18f1ea61b20cbee3ad71be
BLAKE2b-256 548731f2a10beffa33faf09f3937c2c0c0e201dd447c8c20916bb2532801eb2a

See more details on using hashes here.

File details

Details for the file aws_sam_translator-1.58.0-py2-none-any.whl.

File metadata

File hashes

Hashes for aws_sam_translator-1.58.0-py2-none-any.whl
Algorithm Hash digest
SHA256 9aaa3070a205669fdb3821b0c3eccaba1ff7917327c0e7d23dcc16d131d5dc30
MD5 1ab95b7ef251c22a4aa2cc6f07c6cafa
BLAKE2b-256 4872d78f4e4b2790980d7419d60c9d1418a04d2a1a1c057132a46a1c0eab7ffc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page