Skip to main content

AWS SAM transform

Tests Update schema 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: nodejs24.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: nodejs24.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.8+ 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

Workshops and tutorials

Documentation

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.113.0.tar.gz (380.1 kB view details)

Uploaded Source

Built Distribution

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

aws_sam_translator-1.113.0-py3-none-any.whl (446.4 kB view details)

Uploaded Python 3

File details

Details for the file aws_sam_translator-1.113.0.tar.gz.

File metadata

  • Download URL: aws_sam_translator-1.113.0.tar.gz
  • Upload date:
  • Size: 380.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for aws_sam_translator-1.113.0.tar.gz
Algorithm Hash digest
SHA256 3a24b3c5bab9c24b6389cdf18a7a745d338363c57803364e028718fb078259e5
MD5 a4b658008977556e1c291271bbf4d5d6
BLAKE2b-256 21a4a0d384f9dcd3960fb4942e5665ad4c11f10d92a8ba7f517dd6b11df768a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aws_sam_translator-1.113.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2db7e4f7c6ee8fafa89e718a82bfa33b8e97c4e64be643aa3595b27cd7a2e2b
MD5 3696c4886c8c90ec14a738f7042f5e8d
BLAKE2b-256 b822d505dcf1b5e90599655ee7607c44dc756ef866a503e25793ceefd98ba260

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.113.0 This release

2 files

1.112.0

2 files

1.111.0

2 files

1.110.0

2 files

1.109.0

2 files

1.108.0

2 files

1.107.0

2 files

1.106.0

2 files

1.105.0

2 files

1.104.0

2 files

1.103.0

2 files

1.102.0

2 files

1.101.0

2 files

1.100.0

2 files

1.99.0

2 files

1.98.0

2 files

1.97.0

2 files

1.96.0

2 files

1.95.0

2 files

1.94.0

2 files

1.93.0

2 files

1.92.0

2 files

1.91.0

2 files

1.90.0

2 files

1.89.0

2 files

1.88.0

2 files

1.87.0

2 files

1.86.0

2 files

1.85.0

2 files

1.84.0

2 files

1.83.0

2 files

1.82.0

2 files

1.81.0

2 files

1.80.0

2 files

1.79.0

2 files

1.78.0

2 files

1.77.0

2 files

1.76.0

2 files

1.75.0

2 files

1.74.0

2 files

1.73.0

2 files

1.72.0

2 files

1.71.0

2 files

1.70.0

2 files

1.69.0

2 files

1.68.0

2 files

1.67.0

2 files

1.66.0

2 files

1.65.0

2 files

1.64.0

2 files

1.63.0

2 files

1.62.0

2 files

1.61.0

2 files

1.60.1

2 files

1.60.0

2 files

1.59.0

2 files

1.58.1

3 files

1.58.0

3 files

1.57.0

3 files

1.56.0

3 files

1.55.0

3 files

1.54.0

3 files

1.53.0

3 files

1.52.0

3 files

1.51.0

3 files

1.50.0

3 files

1.49.0

3 files

1.48.0

3 files

1.47.0

3 files

1.46.0

3 files

1.45.0

3 files

1.44.0

3 files

1.43.0

3 files

1.42.0

3 files

1.40.0

3 files

1.39.0

3 files

1.38.0

3 files

1.37.0

3 files

1.36.0

3 files

1.35.0

3 files

1.34.0

3 files

1.33.0

3 files

1.32.0

3 files

1.31.0

3 files

1.30.1

3 files

1.30.0

3 files

1.29.0

3 files

1.28.1

3 files

1.27.0

3 files

1.26.0

3 files

1.25.0

3 files

1.24.0

3 files

1.23.0

3 files

1.22.0

1 file

1.21.0

1 file

1.20.1

1 file

1.20.0

1 file

1.19.1

1 file

1.19.0

1 file

1.18.0

1 file

1.17.0

1 file

1.16.0

1 file

1.15.1

1 file

1.15.0

1 file

1.14.0

1 file

1.13.2

1 file

1.13.1

1 file

1.13.0

1 file

1.12.0

1 file

1.11.0

1 file

1.10.0

1 file

1.9.1

1 file

1.9.0

1 file

1.8.0

1 file

1.7.0

1 file

1.6.1

1 file

1.6.0

1 file

1.5.4

1 file

1.5.3

1 file

1.5.2

1 file

1.5.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page