Search⌘ K
AI Features

Further Sections of template​.yaml

Explore the key sections of an AWS SAM template including the description, global settings, and resources. Understand how to define Lambda functions with properties like CodeUri, Handler, and Runtime, and configure event triggers such as API Gateway. Learn best practices for naming resources and how SAM handles IAM permissions automatically. This lesson prepares you to create and deploy serverless web services efficiently.

Description

After the transformation comes the template description:

Description: >
  sam-app

  Sample SAM Template for sam-app

The Description section contains a free-form explanation of the template. This section is useful if you want to publish the template or give it to another team, but it isn’t necessary. You can safely skip it when creating templates for small experiments.

Multi-line text in YAML

YAML files usually contain text values on the same line as the corresponding key. You can use the right angle bracket (>) or a pipe (|) to signal that what follows is multi-line text, indented one level. The difference is that > removes line breaks from the result, and | preserves line breaks.

Global application settings

After the description, the example SAM template contains global application settings. This is a SAM-specific extension to CloudFormation and enables you to reduce the overall template file size by listing common settings in a single place instead of repeating them for each Lambda function. The example template contains just a single function, so adding global values doesn’t make a lot of difference, but this section is useful for more complex applications. The sample template usually contains a global Timeout setting, the number of seconds the function is allowed to run in Lambda:

Globals:
  Function:
    Timeout: 3

Resources

Next comes the Resources section, which lists the services or resources for CloudFormation to configure: ...