MCPcopy Index your code
hub / github.com/aws/serverless-application-model

github.com/aws/serverless-application-model @v1.111.0 sqlite

repository ↗ · DeepWiki ↗ · release v1.111.0 ↗
3,754 symbols 15,303 edges 417 files 929 documented · 25%
README

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:

bash 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

Core symbols most depended-on inside this repo

get
called by 374
samtranslator/sdk/template.py
get
called by 350
samtranslator/model/preferences/deployment_preference_collection.py
items
called by 131
samtranslator/utils/py27hash_fix.py
get_prop
called by 114
samtranslator/internal/schema_source/common.py
passthrough_prop
called by 113
samtranslator/internal/schema_source/common.py
get
called by 104
samtranslator/model/resource_policies.py
ref
called by 74
samtranslator/model/intrinsics.py
get_runtime_attr
called by 73
samtranslator/model/__init__.py

Shape

Method 2,498
Class 746
Function 258
Route 252

Languages

Python100%

Modules by API surface

tests/swagger/test_swagger.py122 symbols
tests/model/test_sam_resources.py122 symbols
tests/intrinsics/test_actions.py106 symbols
samtranslator/model/sam_resources.py105 symbols
tests/translator/test_translator.py88 symbols
tests/utils/test_py27hash_fix.py84 symbols
tests/plugins/api/test_implicit_api_plugin.py76 symbols
samtranslator/internal/schema_source/aws_serverless_function.py59 symbols
tests/openapi/test_openapi.py58 symbols
tests/translator/test_function_resources.py57 symbols
tests/translator/model/preferences/test_deployment_preference_collection.py56 symbols
tests/plugins/application/test_serverless_app_plugin.py55 symbols

Dependencies from manifests, versioned

requests2.25.0 · 1×

For agents

$ claude mcp add serverless-application-model \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact