aws-sam-translator


Nameaws-sam-translator JSON
Version 1.87.0 PyPI version JSON
download
home_pagehttps://github.com/awslabs/serverless-application-model
SummaryAWS SAM Translator is a library that transform SAM templates into AWS CloudFormation templates
upload_time2024-04-04 18:47:26
maintainerNone
docs_urlNone
authorAmazon Web Services
requires_python!=4.0,<=4.0,>=3.8
licenseApache License 2.0
keywords aws sam serverless application model
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # AWS SAM transform

[![Tests](https://github.com/aws/serverless-application-model/actions/workflows/build.yml/badge.svg)](https://github.com/aws/serverless-application-model/actions/workflows/build.yml)
[![Update schema](https://github.com/aws/serverless-application-model/actions/workflows/schema.yml/badge.svg)](https://github.com/aws/serverless-application-model/actions/workflows/schema.yml)
[![PyPI](https://img.shields.io/pypi/v/aws-sam-translator?label=PyPI)](https://pypi.org/project/aws-sam-translator/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws-sam-translator?label=Python)](https://pypi.org/project/aws-sam-translator/)
[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/aws/serverless-application-model.git)

The [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (AWS SAM) transform is a [AWS CloudFormation macro](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html) that transforms [SAM templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy.html) into [CloudFormation templates](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html).

To use the SAM transform, add `AWS::Serverless-2016-10-31` to the [`Transform` section](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html) 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](https://github.com/aws/aws-sam-cli).
- Extension of the CloudFormation template syntax.

## Getting started

Save the following as `template.yaml`:

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

And deploy it with the [SAM CLI](https://github.com/aws/aws-sam-cli):

```bash
sam sync --stack-name sam-app
```

The [`AWS::Serverless::Function`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) resource will create a [AWS Lambda](https://aws.amazon.com/lambda/) function that logs [events](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-concepts.html#gettingstarted-concepts-event) it receives.

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

```yaml
Resources:
  MyFunction:
    Type: AWS::Lambda::Function
    Properties:
      Code:
        ZipFile: |
          exports.handler = async (event) => {
            console.log(event);
          }
      Handler: index.handler
      Role: !GetAtt MyFunctionRole.Arn
      Runtime: nodejs18.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](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html) in the [Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html).

## Contributing

### Setting up development environment

You'll need to have Python 3.8+ installed.

Create a [virtual environment](https://docs.python.org/3/library/venv.html):

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

Set up dependencies:

```bash
make init
```

Run tests:

```bash
make pr
 ```
 
See [`DEVELOPMENT_GUIDE.md`](DEVELOPMENT_GUIDE.md) for further development instructions, and [`CONTRIBUTING.md`](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](https://github.com/aws/serverless-application-model/issues/new/choose) or [start a discussion](https://github.com/aws/serverless-application-model/discussions).

You can also join the [`#samdev` channel](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw) on Slack.

## Learn more

### Workshops and tutorials

- [The Complete AWS SAM Workshop](https://catalog.workshops.aws/complete-aws-sam)
- [AWS Serverless Developer Experience Workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/9a27e484-7336-4ed0-8f90-f2747e4ac65c/en-US)
- [Deploying a "Hello, World!" application](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html)
- [Testing in the cloud using the SAM CLI](https://aws.amazon.com/blogs/compute/accelerating-serverless-development-with-aws-sam-accelerate/)

### Documentation

- [SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)
- [SAM template specification](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html)
- [SAM connectors](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/managing-permissions-connectors.html)
- [SAM policy templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/awslabs/serverless-application-model",
    "name": "aws-sam-translator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=4.0,<=4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "AWS SAM Serverless Application Model",
    "author": "Amazon Web Services",
    "author_email": "aws-sam-developers@amazon.com",
    "download_url": "https://files.pythonhosted.org/packages/a5/b8/41fcb7d76ac74dcdfedf34c73b6ce4f75c19e68534806df319531315c47c/aws-sam-translator-1.87.0.tar.gz",
    "platform": null,
    "description": "# AWS SAM transform\n\n[![Tests](https://github.com/aws/serverless-application-model/actions/workflows/build.yml/badge.svg)](https://github.com/aws/serverless-application-model/actions/workflows/build.yml)\n[![Update schema](https://github.com/aws/serverless-application-model/actions/workflows/schema.yml/badge.svg)](https://github.com/aws/serverless-application-model/actions/workflows/schema.yml)\n[![PyPI](https://img.shields.io/pypi/v/aws-sam-translator?label=PyPI)](https://pypi.org/project/aws-sam-translator/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws-sam-translator?label=Python)](https://pypi.org/project/aws-sam-translator/)\n[![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/aws/serverless-application-model.git)\n\nThe [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (AWS SAM) transform is a [AWS CloudFormation macro](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html) that transforms [SAM templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy.html) into [CloudFormation templates](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html).\n\nTo use the SAM transform, add `AWS::Serverless-2016-10-31` to the [`Transform` section](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html) of your CloudFormation template.\n\nBenefits of using the SAM transform include:\n\n- Built-in best practices and sane defaults.\n- Local testing and debugging with the [AWS SAM CLI](https://github.com/aws/aws-sam-cli).\n- Extension of the CloudFormation template syntax.\n\n## Getting started\n\nSave the following as `template.yaml`:\n\n```yaml\nTransform: AWS::Serverless-2016-10-31\nResources:\n  MyFunction:\n    Type: AWS::Serverless::Function\n    Properties:\n      Runtime: nodejs18.x\n      Handler: index.handler\n      InlineCode: |\n        exports.handler = async (event) => {\n          console.log(event);\n        }\n```\n\nAnd deploy it with the [SAM CLI](https://github.com/aws/aws-sam-cli):\n\n```bash\nsam sync --stack-name sam-app\n```\n\nThe [`AWS::Serverless::Function`](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html) resource will create a [AWS Lambda](https://aws.amazon.com/lambda/) function that logs [events](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-concepts.html#gettingstarted-concepts-event) it receives.\n\nUnder the hood, the template is transformed into the JSON equivalent of the following CloudFormation template:\n\n```yaml\nResources:\n  MyFunction:\n    Type: AWS::Lambda::Function\n    Properties:\n      Code:\n        ZipFile: |\n          exports.handler = async (event) => {\n            console.log(event);\n          }\n      Handler: index.handler\n      Role: !GetAtt MyFunctionRole.Arn\n      Runtime: nodejs18.x\n      Tags:\n        - Key: lambda:createdBy\n          Value: SAM\n  MyFunctionRole:\n    Type: AWS::IAM::Role\n    Properties:\n      AssumeRolePolicyDocument:\n        Version: \"2012-10-17\"\n        Statement:\n          - Action:\n              - sts:AssumeRole\n            Effect: Allow\n            Principal:\n              Service:\n                - lambda.amazonaws.com\n      ManagedPolicyArns:\n        - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\n      Tags:\n        - Key: lambda:createdBy\n          Value: SAM\n```\n\nFor a more thorough introduction, see the [this tutorial](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html) in the [Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html).\n\n## Contributing\n\n### Setting up development environment\n\nYou'll need to have Python 3.8+ installed.\n\nCreate a [virtual environment](https://docs.python.org/3/library/venv.html):\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n```\n\nSet up dependencies:\n\n```bash\nmake init\n```\n\nRun tests:\n\n```bash\nmake pr\n ```\n \nSee [`DEVELOPMENT_GUIDE.md`](DEVELOPMENT_GUIDE.md) for further development instructions, and [`CONTRIBUTING.md`](CONTRIBUTING.md) for the contributing guidelines.\n\n## Getting help\n\nThe best way to interact with the team is through GitHub. You can either [create an issue](https://github.com/aws/serverless-application-model/issues/new/choose) or [start a discussion](https://github.com/aws/serverless-application-model/discussions).\n\nYou can also join the [`#samdev` channel](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw) on Slack.\n\n## Learn more\n\n### Workshops and tutorials\n\n- [The Complete AWS SAM Workshop](https://catalog.workshops.aws/complete-aws-sam)\n- [AWS Serverless Developer Experience Workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/9a27e484-7336-4ed0-8f90-f2747e4ac65c/en-US)\n- [Deploying a \"Hello, World!\" application](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html)\n- [Testing in the cloud using the SAM CLI](https://aws.amazon.com/blogs/compute/accelerating-serverless-development-with-aws-sam-accelerate/)\n\n### Documentation\n\n- [SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)\n- [SAM template specification](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html)\n- [SAM connectors](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/managing-permissions-connectors.html)\n- [SAM policy templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html)\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "AWS SAM Translator is a library that transform SAM templates into AWS CloudFormation templates",
    "version": "1.87.0",
    "project_urls": {
        "Homepage": "https://github.com/awslabs/serverless-application-model"
    },
    "split_keywords": [
        "aws",
        "sam",
        "serverless",
        "application",
        "model"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54c68c9063f025a810fe1f8c55e12ebfd971c1c548914608630a8b12bca52b24",
                "md5": "911b26a4b6ea83b21e59e04d4f0c8f57",
                "sha256": "40cef8980d656107406dafe30aef34b67be33929d2b9492e93f8e9ce07ece1c1"
            },
            "downloads": -1,
            "filename": "aws_sam_translator-1.87.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "911b26a4b6ea83b21e59e04d4f0c8f57",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=4.0,<=4.0,>=3.8",
            "size": 382915,
            "upload_time": "2024-04-04T18:47:23",
            "upload_time_iso_8601": "2024-04-04T18:47:23.782206Z",
            "url": "https://files.pythonhosted.org/packages/54/c6/8c9063f025a810fe1f8c55e12ebfd971c1c548914608630a8b12bca52b24/aws_sam_translator-1.87.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a5b841fcb7d76ac74dcdfedf34c73b6ce4f75c19e68534806df319531315c47c",
                "md5": "2e5df93a21200e9326a87ba29606c352",
                "sha256": "80f4fb6d53774634b6ea84af5fdfa9ad94a46945bc4ad4ef11c8008540dfa7f8"
            },
            "downloads": -1,
            "filename": "aws-sam-translator-1.87.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2e5df93a21200e9326a87ba29606c352",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=4.0,<=4.0,>=3.8",
            "size": 324621,
            "upload_time": "2024-04-04T18:47:26",
            "upload_time_iso_8601": "2024-04-04T18:47:26.460114Z",
            "url": "https://files.pythonhosted.org/packages/a5/b8/41fcb7d76ac74dcdfedf34c73b6ce4f75c19e68534806df319531315c47c/aws-sam-translator-1.87.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-04 18:47:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "awslabs",
    "github_project": "serverless-application-model",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "aws-sam-translator"
}
        
Elapsed time: 0.24929s