AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS::ApiGatewayV2::Route

The AWS::ApiGatewayV2::Route resource creates a route for a WebSocket API. For more information, see Set up Routes for a WebSocket API 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::Route", "Properties" : { "ApiId" : String, "ApiKeyRequired" : Boolean, "AuthorizationScopes" : [ String, ... ], "AuthorizationType" : String, "AuthorizerId" : String, "ModelSelectionExpression" : String, "OperationName" : String, "RequestModels" : Json, "RequestParameters" : Json, "RouteKey" : String, "RouteResponseSelectionExpression" : String, "Target" : String } }

YAML

Type: AWS::ApiGatewayV2::Route Properties: ApiId: String ApiKeyRequired: Boolean AuthorizationScopes: - String AuthorizationType: String AuthorizerId: String ModelSelectionExpression: String OperationName: String RequestModels: Json RequestParameters: Json RouteKey: String RouteResponseSelectionExpression: String Target: String

Properties

ApiId

The API identifier.

Required: Yes

Type: String

Update requires: Replacement

ApiKeyRequired

Specifies whether an API key is required for the route.

Required: No

Type: Boolean

Update requires: No interruption

AuthorizationScopes

The authorization scopes supported by this route.

Required: No

Type: List of String

Update requires: No interruption

AuthorizationType

The authorization type for the route. Valid values are NONE for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a Lambda authorizer.

Required: No

Type: String

Update requires: No interruption

AuthorizerId

The identifier of the Authorizer resource to be associated with this route, if the authorizationType is CUSTOM . The authorizer identifier is generated by API Gateway when you created the authorizer.

Required: No

Type: String

Update requires: No interruption

ModelSelectionExpression

The model selection expression for the route.

Required: No

Type: String

Update requires: No interruption

OperationName

The operation name for the route.

Required: No

Type: String

Update requires: No interruption

RequestModels

The request models for the route.

Required: No

Type: Json

Update requires: No interruption

RequestParameters

The request parameters for the route.

Required: No

Type: Json

Update requires: No interruption

RouteKey

The route key for the route.

Required: Yes

Type: String

Update requires: No interruption

RouteResponseSelectionExpression

The route response selection expression for the route.

Required: No

Type: String

Update requires: No interruption

Target

The target for the route.

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 Route resource ID, such as abcd123.

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

Examples

Route creation example

The following example creates a route resource called MyRoute for a WebSocket API called MyAPI that already has an integration resource called MyIntegration. The route has a route key value of routekey1.

JSON

{ "MyRoute": { "Type": "AWS::ApiGatewayV2::Route", "DependsOn": [ "MyIntegration" ], "Properties": { "ApiId": { "Ref": "MyApi" }, "RouteKey": "routekey1", "AuthorizationType": "NONE", "Target": { "Fn::Join": [ "/", [ "integrations", { "Ref": "MyIntegration" } ] ] } } } }

YAML

MyRoute: Type: 'AWS::ApiGatewayV2::Route' DependsOn: - MyIntegration Properties: ApiId: !Ref MyApi RouteKey: routekey1 AuthorizationType: NONE Target: !Join - / - - integrations - !Ref MyIntegration

See Also

  • CreateRoute in the Amazon API Gateway Version 2 API Reference