Skip to content

aws.apigatewayv2-route resource

Description

Route manages a route on an API Gateway v2 API: the route key that matches incoming requests plus the authorization, request validation, and target settings bound to that key. A route belongs to one API for life, so a change to api-id replaces it; every other field, the route key included, changes in place.

Source: internal/service/apigatewayv2/route_rsrc.go:21

Example usage:

imports: {
  aws: 'github.com/cloudboss/unobin-library-aws'
}

resources: {
  example: aws.apigatewayv2-route {
    # Set input fields here.
  }
}

Inputs

api-id

string

required

ApiId is the API the route belongs to. Changing it replaces the route.

route-key

string

required

RouteKey selects the requests the route handles. For HTTP APIs it is $default or an HTTP method and path such as GET /pets; for WebSocket APIs it is a route selection key such as $connect or $default.

api-key-required

optional(boolean)

ApiKeyRequired requires callers to present an API key. WebSocket APIs only. Unset means false.

authorization-scopes

list(string)

AuthorizationScopes lists the scopes a JWT authorizer matches against the caller's access token. HTTP APIs with a JWT authorizer only.

authorization-type

optional(string)

AuthorizationType is how callers are authorized: NONE, AWS_IAM, CUSTOM, or JWT. JWT applies to HTTP APIs only; WebSocket APIs accept the other three. Unset means NONE.

authorizer-id

optional(string)

AuthorizerId names the authorizer consulted when authorization-type is CUSTOM or JWT.

model-selection-expression

optional(string)

ModelSelectionExpression picks which request model validates a request. WebSocket APIs only.

operation-name

optional(string)

OperationName labels the route for documentation. The API accepts at most 64 characters.

request-models

map(string)

RequestModels maps a content type to the name of the model that validates request bodies. WebSocket APIs only.

request-parameters

map(boolean)

RequestParameters maps a request parameter key, such as route.request.header.x-api-key, to whether the parameter is required. WebSocket APIs only.

route-response-selection-expression

optional(string)

RouteResponseSelectionExpression picks the route response for a request. WebSocket APIs only.

target

optional(string)

Target is the integration the route invokes, in the form integrations/<integration-id>. The API accepts at most 128 characters.

Input Constraints

Authorization type rules

authorization-type must be NONE, AWS_IAM, CUSTOM, or JWT.

Rule logic
When
input.authorization-type != null
Require
input.authorization-type == 'NONE'
|| input.authorization-type == 'AWS_IAM'
|| input.authorization-type == 'CUSTOM'
|| input.authorization-type == 'JWT'

authorizer-id is required when authorization-type is CUSTOM or JWT.

Rule logic
When
input.authorization-type == 'CUSTOM'
|| input.authorization-type == 'JWT'
Require
input.authorizer-id != null

Operation name rules

operation-name must not be empty.

Rule logic
When
input.operation-name != null
Require
input.operation-name != null
&& @core.length(input.operation-name) >= 1

Target rules

target must not be empty.

Rule logic
When
input.target != null
Require
input.target != null
&& @core.length(input.target) >= 1

Outputs

api-id

string

route-id

string