routes
Creates, updates, deletes or gets a route resource or lists routes in a region
Overview
| Name | routes |
| Type | Resource |
| Description | The AWS::ApiGatewayV2::Route resource creates a route for an API. |
| Id | awscc.apigatewayv2.routes |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
route_id | string | |
route_response_selection_expression | string | The route response selection expression for the route. Supported only for WebSocket APIs. |
request_models | object | The request models for the route. Supported only for WebSocket APIs. |
operation_name | string | The operation name for the route. |
authorization_scopes | array | The authorization scopes supported by this route. |
api_key_required | boolean | Specifies whether an API key is required for the route. Supported only for WebSocket APIs. |
route_key | string | The 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_type | string | The 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_expression | string | The model selection expression for the route. Supported only for WebSocket APIs. |
api_id | string | The API identifier. |
request_parameters | object | The request parameters for the route. Supported only for WebSocket APIs. |
target | string | The target for the route. |
authorizer_id | string | The identifier of the Authorizer resource to be associated with this route. The authorizer identifier is generated by API Gateway when you created the authorizer. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
route_id | string | |
api_id | string | The API identifier. |
region | string | AWS region. |
For more information, see AWS::ApiGatewayV2::Route.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | routes | INSERT | RouteKey, ApiId, region |
delete_resource | routes | DELETE | Identifier, region |
update_resource | routes | UPDATE | Identifier, PatchDocument, region |
list_resources | routes_list_only | SELECT | region |
get_resource | routes | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
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 }}';
Lists all routes in a region.
SELECT
region,
api_id,
route_id
FROM awscc.apigatewayv2.routes_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new route resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ 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
;
/*+ create */
INSERT INTO awscc.apigatewayv2.routes (
RouteResponseSelectionExpression,
RequestModels,
OperationName,
AuthorizationScopes,
ApiKeyRequired,
RouteKey,
AuthorizationType,
ModelSelectionExpression,
ApiId,
RequestParameters,
Target,
AuthorizerId,
region
)
SELECT
'{{ 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 }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: route
props:
- name: route_response_selection_expression
value: '{{ route_response_selection_expression }}'
- name: request_models
value: {}
- name: operation_name
value: '{{ operation_name }}'
- name: authorization_scopes
value:
- '{{ authorization_scopes[0] }}'
- name: api_key_required
value: '{{ api_key_required }}'
- name: route_key
value: '{{ route_key }}'
- name: authorization_type
value: '{{ authorization_type }}'
- name: model_selection_expression
value: '{{ model_selection_expression }}'
- name: api_id
value: '{{ api_id }}'
- name: request_parameters
value: {}
- name: target
value: '{{ target }}'
- name: authorizer_id
value: '{{ authorizer_id }}'
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:
| Parameter | Description |
|---|---|
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:
- Create
- Update
- Read
- Delete
- List
apigateway:POST
apigateway:PATCH,
apigateway:GET,
apigateway:PUT
apigateway:GET
apigateway:GET,
apigateway:DELETE
apigateway:GET