CLI tool
aws/serverless-application-model avatar
aws/serverless-application-model

AWS SAM transform: what the CloudFormation macro actually does

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

9,573 stars2,459 forksPythonApache-2.0

At a glance

What is it?
The AWS Serverless Application Model repository ships the CloudFormation macro that expands AWS::Serverless resources into plain CloudFormation, plus the aws-sam-translator library behind it. Here is how the transform works, how to try it with the SAM CLI, and where it stops being the right tool.
Who is it for?
Adopt the SAM transform if you want CloudFormation as your deployment engine but not the verbosity of hand-written Lambda, IAM and event source resources. Skip it if your templates are already plain CloudFormation, or if you need a provider-neutral deployment format.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem: CloudFormation is verbose for small Lambda services

A single Lambda function behind an HTTP endpoint is not one CloudFormation resource. It is a function, an execution role, an assume-role policy, one or more managed policy attachments, a log group if you want retention, a permission for the event source, and the event source mapping itself. None of that is hard to write, and all of it is repetitive.

The AWS SAM transform exists to compress that repetition. According to the README, it is "a AWS CloudFormation macro that transforms SAM templates into CloudFormation templates." You write AWS::Serverless::Function instead of AWS::Lambda::Function, and the macro fills in the role, the basic execution policy and the tags. The README lists the intended benefits as built-in best practices and sane defaults, local testing and debugging with the AWS SAM CLI, and an extension of the CloudFormation template syntax.

That framing matters for who this is for. The audience is teams already committed to CloudFormation as their deployment mechanism, who want a shorter authoring surface without leaving it. It is not a framework that replaces CloudFormation, and it does not deploy anything by itself. The transform runs inside CloudFormation; the SAM CLI is a separate repository.

How the transform expands a SAM template

The entry point is a single template line. Adding AWS::Serverless-2016-10-31 to the Transform section tells CloudFormation to run the SAM macro over the template before it processes resources. The date is part of the transform name, so it is not a version you bump; it identifies the transform.

The README walks through one function and shows both sides. On the input side there is one resource, AWS::Serverless::Function, with Runtime, Handler and InlineCode. On the output side, described as "the JSON equivalent of the following CloudFormation template", there are two resources. The function becomes AWS::Lambda::Function with the same code, handler and runtime, plus a Role pointing at a generated role. The second resource, MyFunctionRole, is an AWS::IAM::Role with an assume-role policy for lambda.amazonaws.com and the managed policy arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole. Both resources carry a tag with the key lambda:createdBy and the value SAM.

That tag is the practical way to tell generated resources apart from ones you wrote. It also means the expansion is not purely cosmetic: adopting the transform adds IAM resources you did not author, and their names are derived from your logical IDs. The repository layout reflects this split. The samtranslator package holds the transformation logic, schema_source and samtranslator/schema hold the generated schema, and tests/translator/output holds expected translator output, which is where the expansion behaviour is pinned down.

Installing the SAM CLI and deploying a first function

The README does not give pip installation instructions for the translator; the repository is the source of the transform, and the README points at the SAM CLI for deployment and at the Developer Guide for a fuller introduction. The development section is explicit that you need Python 3.8 or newer, and it uses a virtual environment plus make targets.

Start by creating the template the README provides, saved as template.yaml. It declares the transform, one function, and inline JavaScript that logs the event it receives.

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);
        }

Deploy it with the SAM CLI. The README gives this exact command, with the stack name sam-app:

bash
sam sync --stack-name sam-app

After the stack reaches a completed state, the function exists and logs events. What you should see in the CloudFormation console is not MyFunction alone but MyFunction plus the generated role the README prints, both tagged with lambda:createdBy set to SAM. If you only see the function type you expected and no role, the transform did not run, which almost always means the Transform line is missing or misspelled.

If you want to work on the transform itself rather than use it, the README's development path is a virtual environment followed by make init and make pr:

bash
python3 -m venv .venv
source .venv/bin/activate
make init
make pr

The Makefile shows make init running pip install -e '.[dev]', and the test target running pytest with a coverage floor of 95 percent. The DEVELOPMENT_GUIDE.md and CONTRIBUTING.md files are where the README sends you for anything beyond that.

Where the transform is the wrong tool

The transform only helps if CloudFormation is already your deployment path. If you deploy with Terraform, CDK, or a non-AWS control plane, the macro never runs, and the SAM template is just a file nothing reads. The README is clear that the transform is a CloudFormation macro, so the dependency is structural, not a matter of preference.

There is a second, subtler limit. Because the transform generates resources, the template you review and the template CloudFormation executes are not the same document. The README prints the expanded form for one trivial function; a real template with several functions, APIs and event sources expands into considerably more. Debugging a failed deployment means reasoning about resources you never wrote, and the logical IDs of generated resources follow conventions the README does not enumerate. That is a real cost, and it is the main reason teams sometimes move to plain CloudFormation once their service stabilises.

The repository also sets its own bar high for contributors rather than users: the test target enforces 95 percent coverage, and format-check regenerates the schema and diffs it against the committed files. A failing format-check is not a style nit; per the Makefile comment, it can mean the committed schema is stale relative to the code, and you are told to run make schema.

SAM transform versus Serverless Framework versus plain CloudFormation

The closest comparison is the Serverless Framework, which people search for alongside SAM. Both let you describe a Lambda function in a few lines, but the mechanism differs. The Serverless Framework is a CLI that reads its own configuration format and drives provider APIs; it is not a CloudFormation macro, so its output is not a CloudFormation template you can inspect and continue editing. The SAM transform produces exactly that: a CloudFormation template, which is why you can mix AWS::Serverless::Function and AWS::Lambda::Function in one file and deploy the result as a single stack.

The comparison with plain CloudFormation runs the other way. Plain CloudFormation gives you the full resource set with no expansion step, at the cost of writing the role, the policy attachment and the tags yourself. The README's own example makes the trade-off visible: one resource in, two resources out, one of which is an IAM role you did not author. If you would rather own that role explicitly, the transform is adding indirection rather than removing work.

A related but distinct thing is the AWS Serverless Application Repository, which people also search for. It is a catalogue of applications, not the transform; the transform is what would expand a template if you deployed one. Do not treat them as interchangeable.

Release cadence, licence and what upgrading costs

The repository is not archived, and the most recent push recorded is on 2026-09-15. Recent releases are v1.113.0 on 2026-08-24, v1.112.0 on 2026-08-13, and v1.111.0 on 2026-07-02. The gap between v1.111.0 and v1.112.0 is roughly six weeks, so the cadence is not strictly monthly.

Because the transform is invoked by CloudFormation rather than pinned in your project, upgrading is not a dependency bump you control. You do not choose the translator version that expands your template; CloudFormation does. What you can pin is the aws-sam-translator library if you call it directly, and the SAM CLI version you use locally. That means a template that expands correctly today can expand differently later, and the release notes are the place that change would be announced. The README does not document rollback or a way to pin the transform to a specific translator version, so if you need reproducible expansion you should verify that yourself before relying on it.

The licence is Apache-2.0, per the repository's LICENSE file, with a NOTICE file and a THIRD_PARTY_LICENSES file alongside it. Apache-2.0 permits commercial use and modification and includes a patent grant; the NOTICE and third-party licence files mean there are bundled dependencies whose terms travel with the project. If you redistribute the translator as part of a product, read those files rather than assuming the single licence identifier covers everything. This is a description of what is in the repository, not legal advice.

Editorial conclusion

Adopt the SAM transform if you want CloudFormation as your deployment engine but not the verbosity of hand-written Lambda, IAM and event source resources. Skip it if your templates are already plain CloudFormation, or if you need a provider-neutral deployment format. Before committing, deploy the README's template.yaml and diff the resulting CloudFormation against the expanded template the README prints, so you know exactly which resources the transform adds on your behalf.

Frequently asked questions

What is the AWS SAM transform?

It is an AWS CloudFormation macro that transforms SAM templates into CloudFormation templates. You enable it by adding AWS::Serverless-2016-10-31 to the Transform section of a CloudFormation template.

Can you give me an example of a serverless application with AWS SAM?

The README's example is a template.yaml with the transform line and one AWS::Serverless::Function using Runtime nodejs24.x, Handler index.handler and InlineCode that logs the event. Deployed with the SAM CLI, it expands into an AWS::Lambda::Function plus a generated AWS::IAM::Role.

How do I install the AWS SAM transform?

You do not install the transform as a package; it runs inside CloudFormation when a template declares AWS::Serverless-2016-10-31 in its Transform section. The README points to the AWS SAM CLI for deploying and testing, and to the Developer Guide for a fuller introduction.

Does the SAM transform replace CloudFormation?

No. The README describes it as a CloudFormation macro that transforms SAM templates into CloudFormation templates, so CloudFormation still performs the deployment. You can mix AWS::Serverless and plain CloudFormation resources in the same template.

What does the AWS::Serverless::Function resource create?

The README shows it expanding into an AWS::Lambda::Function with the code, handler and runtime you specified, plus an AWS::IAM::Role carrying the AWSLambdaBasicExecutionRole managed policy. Both generated resources are tagged with lambda:createdBy set to SAM.

What Python version does the SAM transform repository require?

The README's development section states you need Python 3.8 or newer, and it sets up a virtual environment before running make init and make pr. The Makefile's test target runs pytest with a coverage floor of 95 percent.

Official sources

  1. aws/serverless-application-model on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/aws-serverless-application-model.svg)](https://hysenlabs.com/projects/aws-serverless-application-model)