Skip to main content

routes

Creates, updates, deletes, gets or lists a routes resource.

Overview

Nameroutes
TypeResource
Idaws.apigatewayv2.routes

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
api_gateway_managedbooleanSpecifies whether a route is managed by API Gateway. If you created an API using quick create, the $default route is managed by API Gateway. You can't modify the $default route key.
api_key_requiredbooleanSpecifies whether an API key is required for this route. Supported only for WebSocket APIs.
authorization_scopesarrayA list of authorization scopes configured on a route. The scopes are used with a JWT authorizer to authorize the method invocation. The authorization works by matching the route scopes against the scopes parsed from the access token in the incoming request. The method invocation is authorized if any route scope matches a claimed scope in the access token. Otherwise, the invocation is not authorized. When the route scope is configured, the client must provide an access token instead of an identity token for authorization purposes.
authorization_typestringThe authorization type. For WebSocket APIs, valid values are NONE for open access, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a Lambda authorizer. For HTTP APIs, valid values are NONE for open access, JWT for using JSON Web Tokens, AWS_IAM for using AWS IAM permissions, and CUSTOM for using a Lambda authorizer. (NONE, AWS_IAM, CUSTOM, JWT)
authorizer_idstringThe identifier.
model_selection_expressionstringAn expression used to extract information at runtime. See Selection Expressions for more information.
operation_namestringA string with a length between [1-64].
request_modelsobjectThe request models for the route. Supported only for WebSocket APIs.
request_parametersobjectThe request parameters for the route. Supported only for WebSocket APIs.
route_idstringThe identifier.
route_keystringAfter evaluating a selection expression, the result is compared against one or more selection keys to find a matching key. See Selection Expressions for a list of expressions and each expression's associated selection key type.
route_response_selection_expressionstringAn expression used to extract information at runtime. See Selection Expressions for more information.
targetstringA string with a length between [1-128].

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_routeselectapi_id, route_id, regionGets a Route.
get_routesselectapi_id, regionmaxResults, nextTokenGets the Routes for an API.
create_routeinsertapi_id, region, RouteKeyCreates a Route for an API.
update_routeupdateapi_id, route_id, regionUpdates a Route.
delete_route_request_parameterdeleteapi_id, request_parameter_key, route_id, regionDeletes a route request parameter. Supported only for WebSocket APIs.
delete_route_settingsdeleteapi_id, route_key, stage_name, regionDeletes the RouteSettings for a stage.
delete_routedeleteapi_id, route_id, regionDeletes a Route.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_idstringThe API identifier.
regionstringAWS region (default: us-east-1)
request_parameter_keystringThe route request parameter key.
route_idstringThe route ID.
route_keystringThe route key.
stage_namestringThe stage name. Stage names can only contain alphanumeric characters, hyphens, and underscores. Maximum length is 128 characters.
maxResultsstringThe maximum number of elements to be returned for this resource.
nextTokenstringThe next page of elements from this collection. Not valid for the last element of the collection.

SELECT examples

Gets a Route.

SELECT
api_gateway_managed,
api_key_required,
authorization_scopes,
authorization_type,
authorizer_id,
model_selection_expression,
operation_name,
request_models,
request_parameters,
route_id,
route_key,
route_response_selection_expression,
target
FROM aws.apigatewayv2.routes
WHERE api_id = '{{ api_id }}' -- required
AND route_id = '{{ route_id }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Creates a Route for an API.

INSERT INTO aws.apigatewayv2.routes (
ApiKeyRequired,
AuthorizationScopes,
AuthorizationType,
AuthorizerId,
ModelSelectionExpression,
OperationName,
RequestModels,
RequestParameters,
RouteKey,
RouteResponseSelectionExpression,
Target,
api_id,
region
)
SELECT
{{ ApiKeyRequired }},
'{{ AuthorizationScopes }}',
'{{ AuthorizationType }}',
'{{ AuthorizerId }}',
'{{ ModelSelectionExpression }}',
'{{ OperationName }}',
'{{ RequestModels }}',
'{{ RequestParameters }}',
'{{ RouteKey }}' /* required */,
'{{ RouteResponseSelectionExpression }}',
'{{ Target }}',
'{{ api_id }}',
'{{ region }}'
RETURNING
api_gateway_managed,
api_key_required,
authorization_scopes,
authorization_type,
authorizer_id,
model_selection_expression,
operation_name,
request_models,
request_parameters,
route_id,
route_key,
route_response_selection_expression,
target
;

UPDATE examples

Updates a Route.

UPDATE aws.apigatewayv2.routes
SET
ApiKeyRequired = {{ ApiKeyRequired }},
AuthorizationScopes = '{{ AuthorizationScopes }}',
AuthorizationType = '{{ AuthorizationType }}',
AuthorizerId = '{{ AuthorizerId }}',
ModelSelectionExpression = '{{ ModelSelectionExpression }}',
OperationName = '{{ OperationName }}',
RequestModels = '{{ RequestModels }}',
RequestParameters = '{{ RequestParameters }}',
RouteKey = '{{ RouteKey }}',
RouteResponseSelectionExpression = '{{ RouteResponseSelectionExpression }}',
Target = '{{ Target }}'
WHERE
api_id = '{{ api_id }}' --required
AND route_id = '{{ route_id }}' --required
AND region = '{{ region }}' --required
RETURNING
api_gateway_managed,
api_key_required,
authorization_scopes,
authorization_type,
authorizer_id,
model_selection_expression,
operation_name,
request_models,
request_parameters,
route_id,
route_key,
route_response_selection_expression,
target;

DELETE examples

Deletes a route request parameter. Supported only for WebSocket APIs.

DELETE FROM aws.apigatewayv2.routes
WHERE api_id = '{{ api_id }}' --required
AND request_parameter_key = '{{ request_parameter_key }}' --required
AND route_id = '{{ route_id }}' --required
AND region = '{{ region }}' --required
;