Api - Amazon Serverless Application Model
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Api

The object describing an Api event source type. If an AWS::Serverless::Api resource is defined, the path and method values must correspond to an operation in the OpenAPI definition of the API.

Syntax

To declare this entity in your Amazon Serverless Application Model (Amazon SAM) template, use the following syntax.

YAML

Auth: ApiStateMachineAuth Method: String Path: String RestApiId: String UnescapeMappingTemplate: Boolean

Properties

Auth

The authorization configuration for this API, path, and method.

Use this property to override the API's DefaultAuthorizer setting for an individual path, when no DefaultAuthorizer is specified, or to override the default ApiKeyRequired setting.

Type: ApiStateMachineAuth

Required: No

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

Method

The HTTP method for which this function is invoked.

Type: String

Required: Yes

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

Path

The URI path for which this function is invoked. The value must start with /.

Type: String

Required: Yes

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

RestApiId

The identifier of a RestApi resource, which must contain an operation with the given path and method. Typically, this is set to reference an AWS::Serverless::Api resource that is defined in this template.

If you don't define this property, Amazon SAM creates a default AWS::Serverless::Api resource using a generated OpenApi document. That resource contains a union of all paths and methods defined by Api events in the same template that do not specify a RestApiId.

This property can't reference an AWS::Serverless::Api resource that is defined in another template.

Type: String

Required: No

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

UnescapeMappingTemplate

Unescapes single quotes, by replacing \' with ', on the input that is passed to the state machine. Use when your input contains single quotes.

Note

If set to False and your input contains single quotes, an error will occur.

Type: Boolean

Required: No

Default: False

Amazon CloudFormation compatibility: This property is unique to Amazon SAM and doesn't have an Amazon CloudFormation equivalent.

Examples

ApiEvent

The following is an example of an event of the Api type.

YAML

Events: ApiEvent: Type: Api Properties: Path: /path Method: get