AWS CloudFormation
User Guide (Version )

AWS::ApiGatewayV2::Api

The AWS::ApiGatewayV2::Api resource creates an API. Currently only WebSocket APIs are supported. For more information about WebSocket APIs, see About WebSocket APIs in API Gateway in the API Gateway Developer Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::ApiGatewayV2::Api", "Properties" : { "ApiKeySelectionExpression" : String, "Description" : String, "DisableSchemaValidation" : Boolean, "Name" : String, "ProtocolType" : String, "RouteSelectionExpression" : String, "Tags" : Json, "Version" : String } }

YAML

Type: AWS::ApiGatewayV2::Api Properties: ApiKeySelectionExpression: String Description: String DisableSchemaValidation: Boolean Name: String ProtocolType: String RouteSelectionExpression: String Tags: Json Version: String

Properties

ApiKeySelectionExpression

An API key selection expression. See API Key Selection Expressions.

Required: No

Type: String

Update requires: No interruption

Description

The description of the API.

Required: No

Type: String

Update requires: No interruption

DisableSchemaValidation

Avoid validating models when creating a deployment.

Required: No

Type: Boolean

Update requires: No interruption

Name

The name of the API.

Required: Yes

Type: String

Update requires: No interruption

ProtocolType

The API protocol: Currently only WEBSOCKET is supported.

Required: Yes

Type: String

Update requires: Replacement

RouteSelectionExpression

The route selection expression for the API.

Required: Yes

Type: String

Update requires: No interruption

Tags

The collection of tags. Each tag element is associated with a given resource.

Required: No

Type: Json

Update requires: No interruption

Version

A version identifier for the API.

Required: No

Type: String

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the API ID, such as a1bcdef2gh.

For more information about using the Ref function, see Ref.

Examples

API creation example

The following example creates an Api resource called MyApi.

JSON

{ "MyApi": { "Type": "AWS::ApiGatewayV2::Api", "Properties": { "Name": "MyApi", "ProtocolType": "WEBSOCKET", "RouteSelectionExpression": "$request.body.action", "ApiKeySelectionExpression": "$request.header.x-api-key" } } }

YAML

MyApi: Type: 'AWS::ApiGatewayV2::Api' Properties: Name: MyApi ProtocolType: WEBSOCKET RouteSelectionExpression: $request.body.action ApiKeySelectionExpression: $request.header.x-api-key

See Also

  • CreateApi in the Amazon API Gateway Version 2 API Reference