Skip to main content

routes

Creates, updates, deletes or gets a route resource or lists routes in a region

Overview

Nameroutes
TypeResource
DescriptionThe AWS::ApiGatewayV2::Route resource creates a route for an API.
Idawscc.apigatewayv2.routes

Fields

NameDatatypeDescription
route_idstring
route_response_selection_expressionstringThe route response selection expression for the route. Supported only for WebSocket APIs.
request_modelsobjectThe request models for the route. Supported only for WebSocket APIs.
operation_namestringThe operation name for the route.
authorization_scopesarrayThe authorization scopes supported by this route.
api_key_requiredbooleanSpecifies whether an API key is required for the route. Supported only for WebSocket APIs.
route_keystringThe route key for the route. For HTTP APIs, the route key can be either $default, or a combination of an HTTP method and resource path, for example, GET /pets.
authorization_typestringThe authorization type for the route. 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.
model_selection_expressionstringThe model selection expression for the route. Supported only for WebSocket APIs.
api_idstringThe API identifier.
request_parametersobjectThe request parameters for the route. Supported only for WebSocket APIs.
targetstringThe target for the route.
authorizer_idstringThe identifier of the Authorizer resource to be associated with this route. The authorizer identifier is generated by API Gateway when you created the authorizer.
regionstringAWS region.

For more information, see AWS::ApiGatewayV2::Route.

Methods

NameResourceAccessible byRequired Params
create_resourceroutesINSERTRouteKey, ApiId, region
delete_resourceroutesDELETEIdentifier, region
update_resourceroutesUPDATEIdentifier, PatchDocument, region
list_resourcesroutes_list_onlySELECTregion
get_resourceroutesSELECTIdentifier, region

SELECT examples

Gets all properties from an individual route.

SELECT
region,
route_id,
route_response_selection_expression,
request_models,
operation_name,
authorization_scopes,
api_key_required,
route_key,
authorization_type,
model_selection_expression,
api_id,
request_parameters,
target,
authorizer_id
FROM awscc.apigatewayv2.routes
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_id }}|{{ route_id }}';

INSERT example

Use the following StackQL query and manifest file to create a new route resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.apigatewayv2.routes (
RouteKey,
ApiId,
region
)
SELECT
'{{ route_key }}',
'{{ api_id }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

Use the following StackQL query and manifest file to update a route resource, using stack-deploy.

/*+ update */
UPDATE awscc.apigatewayv2.routes
SET PatchDocument = string('{{ {
"RouteResponseSelectionExpression": route_response_selection_expression,
"RequestModels": request_models,
"OperationName": operation_name,
"AuthorizationScopes": authorization_scopes,
"ApiKeyRequired": api_key_required,
"RouteKey": route_key,
"AuthorizationType": authorization_type,
"ModelSelectionExpression": model_selection_expression,
"RequestParameters": request_parameters,
"Target": target,
"AuthorizerId": authorizer_id
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ api_id }}|{{ route_id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.apigatewayv2.routes
WHERE
Identifier = '{{ api_id }}|{{ route_id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the routes resource, the following permissions are required:

apigateway:POST