AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

WebSocketApi

Create a new API Gateway WebSocket API endpoint.

Import

import { WebSocketApi } from 'aws-cdk-lib/aws-apigatewayv2';

Or use the module namespace:

import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2';
// apigatewayv2.WebSocketApi

Properties

Configuration passed to the constructor as WebSocketApiProps.

apiKeySelectionExpressionOptional
WebSocketApiKeySelectionExpression

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

apiNameOptional
string

Name for the WebSocket API resource.

Default: - id of the WebSocketApi construct.

connectRouteOptionsOptional
WebSocketRouteOptions

Options to configure a '$connect' route.

Default: - no '$connect' route configured

defaultRouteOptionsOptional
WebSocketRouteOptions

Options to configure a '$default' route.

Default: - no '$default' route configured

descriptionOptional
string

The description of the API.

Default: - none

disableSchemaValidationOptional
boolean

Avoid validating models when creating a deployment.

Default: false

disconnectRouteOptionsOptional
WebSocketRouteOptions

Options to configure a '$disconnect' route.

Default: - no '$disconnect' route configured

ipAddressTypeOptional
IpAddressType

The IP address types that can invoke the API.

Default: undefined - AWS default is IPV4

routeSelectionExpressionOptional
string

The route selection expression for the API.

Default: '$request.body.action'

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter