WebSocketApiProps

class aws_cdk.aws_apigatewayv2.WebSocketApiProps(*, api_key_selection_expression=None, api_name=None, connect_route_options=None, default_route_options=None, description=None, disconnect_route_options=None, route_selection_expression=None)

Bases: object

(experimental) Props for WebSocket API.

Parameters
  • api_key_selection_expression (Optional[WebSocketApiKeySelectionExpression]) – (experimental) An API key selection expression. Providing this option will require an API Key be provided to access the API. Default: - Key is not required to access these APIs

  • api_name (Optional[str]) – (experimental) Name for the WebSocket API resource. Default: - id of the WebSocketApi construct.

  • connect_route_options (Optional[WebSocketRouteOptions]) – (experimental) Options to configure a ‘$connect’ route. Default: - no ‘$connect’ route configured

  • default_route_options (Optional[WebSocketRouteOptions]) – (experimental) Options to configure a ‘$default’ route. Default: - no ‘$default’ route configured

  • description (Optional[str]) – (experimental) The description of the API. Default: - none

  • disconnect_route_options (Optional[WebSocketRouteOptions]) – (experimental) Options to configure a ‘$disconnect’ route. Default: - no ‘$disconnect’ route configured

  • route_selection_expression (Optional[str]) – (experimental) The route selection expression for the API. Default: ‘$request.body.action’

Stability

experimental

ExampleMetadata

infused

Example:

from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration

# connect_handler: lambda.Function
# disconnect_handler: lambda.Function
# default_handler: lambda.Function


web_socket_api = apigwv2.WebSocketApi(self, "mywsapi",
    connect_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("ConnectIntegration", connect_handler)),
    disconnect_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("DisconnectIntegration", disconnect_handler)),
    default_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("DefaultIntegration", default_handler))
)

apigwv2.WebSocketStage(self, "mystage",
    web_socket_api=web_socket_api,
    stage_name="dev",
    auto_deploy=True
)

Attributes

api_key_selection_expression

(experimental) An API key selection expression.

Providing this option will require an API Key be provided to access the API.

Default
  • Key is not required to access these APIs

Stability

experimental

Return type

Optional[WebSocketApiKeySelectionExpression]

api_name

(experimental) Name for the WebSocket API resource.

Default
  • id of the WebSocketApi construct.

Stability

experimental

Return type

Optional[str]

connect_route_options

(experimental) Options to configure a ‘$connect’ route.

Default
  • no ‘$connect’ route configured

Stability

experimental

Return type

Optional[WebSocketRouteOptions]

default_route_options

(experimental) Options to configure a ‘$default’ route.

Default
  • no ‘$default’ route configured

Stability

experimental

Return type

Optional[WebSocketRouteOptions]

description

(experimental) The description of the API.

Default
  • none

Stability

experimental

Return type

Optional[str]

disconnect_route_options

(experimental) Options to configure a ‘$disconnect’ route.

Default
  • no ‘$disconnect’ route configured

Stability

experimental

Return type

Optional[WebSocketRouteOptions]

route_selection_expression

(experimental) The route selection expression for the API.

Default

‘$request.body.action’

Stability

experimental

Return type

Optional[str]