Which resource does AWS serverless application model syntax expand and transform into?

AWS::Serverless transform

The AWS::Serverless transform, which is a macro hosted by CloudFormation, takes an entire template written in the AWS Serverless Application Model (AWS SAM) syntax and transforms and expands it into a compliant CloudFormation template. For more information about serverless applications and AWS SAM, see Deploying Lambda-based applications in the AWS Lambda Developer Guide and AWS SAM resource and property reference in the AWS Serverless Application Model Developer Guide.

In the following example, the template uses AWS SAM syntax to simplify the declaration of a Lambda function and its execution role.

Transform: AWS::Serverless-2016-10-31
Resources:
  MyServerlessFunctionLogicalID:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs8.10
      CodeUri: 's3://testBucket/mySourceCode.zip'

When creating a change set from the template, CloudFormation expands the AWS SAM syntax, as defined by the transform. The processed template expands the AWS::Serverless::Function resource, declaring an AWS Lambda function and an execution role.

{
  "Resources": {
    "MyServerlessFunctionLogicalID": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Handler": "index.handler",
        "Code": {
          "S3Bucket": "testBucket",
          "S3Key": "mySourceCode.zip"
        },
        "Role": {
          "Fn::GetAtt": ["FunctionNameRole", "Arn"]
        },
        "Runtime": "nodejs8.10"
      }
    },
    "FunctionNameRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "ManagedPolicyArns": ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"],
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [{
            "Action": ["sts:AssumeRole"],
            "Effect": "Allow",
            "Principal": {
              "Service": ["lambda.amazonaws.com"]
            }
          }]
        }
      }
    }
  }
}

Syntax

The value for the transform declaration must be a literal string. You can't use a parameter or function to specify a transform value. The following snippet is an example of a transform declaration:

JSON

"Transform" : "AWS::Serverless-2016-10-31"

YAML

Transform: "AWS::Serverless-2016-10-31"

The AWS::Serverless transform, which is a macro hosted by CloudFormation, takes an entire template written in the Amazon Serverless Application Model (Amazon SAM) syntax and transforms and expands it into a compliant CloudFormation template. For more information about serverless applications and Amazon SAM, see Deploying Lambda-based applications in the Amazon Lambda Developer Guide and Amazon SAM resource and property reference in the Amazon Serverless Application Model Developer Guide.

In the following example, the template uses Amazon SAM syntax to simplify the declaration of a Lambda function and its execution role.

Transform: AWS::Serverless-2016-10-31
Resources:
  MyServerlessFunctionLogicalID:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs8.10
      CodeUri: 's3://testBucket/mySourceCode.zip'

When creating a change set from the template, CloudFormation expands the Amazon SAM syntax, as defined by the transform. The processed template expands the AWS::Serverless::Function resource, declaring an Amazon Lambda function and an execution role.

{
  "Resources": {
    "MyServerlessFunctionLogicalID": {
      "Type": "AWS::Lambda::Function",
      "Properties": {
        "Handler": "index.handler",
        "Code": {
          "S3Bucket": "testBucket",
          "S3Key": "mySourceCode.zip"
        },
        "Role": {
          "Fn::GetAtt": ["FunctionNameRole", "Arn"]
        },
        "Runtime": "nodejs8.10"
      }
    },
    "FunctionNameRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "ManagedPolicyArns": ["arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"],
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [{
            "Action": ["sts:AssumeRole"],
            "Effect": "Allow",
            "Principal": {
              "Service": ["lambda.amazonaws.com"]
            }
          }]
        }
      }
    }
  }
}

Syntax

The value for the transform declaration must be a literal string. You can't use a parameter or function to specify a transform value. The following snippet is an example of a transform declaration:

JSON

"Transform" : "AWS::Serverless-2016-10-31"

YAML

Transform: "AWS::Serverless-2016-10-31"

Which resource does AWS serverless application model AWS SAM syntax expand and transform into?

Build serverless applications in simple and clean syntax During deployment, SAM transforms and expands the SAM syntax into AWS CloudFormation syntax, enabling you to build serverless applications faster.

Which resources can be specified in the AWS serverless application model?

Note that a serverless application is more than just a Lambda function—it can include additional resources such as APIs, databases, and event source mappings. You can use AWS SAM to define your serverless applications.

Which section of the AWS serverless application model template is required and identifies an AWS CloudFormation template file as an AWS SAM template file?

Transform declaration. The declaration Transform: AWS::Serverless-2016-10-31 is required for AWS SAM template files. This declaration identifies an AWS CloudFormation template file as an AWS SAM template file. For more information about transforms, see Transform in the AWS CloudFormation User Guide.

Which AWS service or resource is serverless?

AWS Lambda is an event-driven, pay-as-you-go compute service that lets you run code without provisioning or managing servers.