WebSocketLambdaIntegration

class aws_cdk.aws_apigatewayv2_integrations.WebSocketLambdaIntegration(id, handler, *, content_handling=None, timeout=None)

Bases: WebSocketRouteIntegration

Lambda WebSocket Integration.

ExampleMetadata:

infused

Example:

from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration

# message_handler: lambda.Function


web_socket_api = apigwv2.WebSocketApi(self, "mywsapi")
apigwv2.WebSocketStage(self, "mystage",
    web_socket_api=web_socket_api,
    stage_name="dev",
    auto_deploy=True
)
web_socket_api.add_route("sendMessage",
    integration=WebSocketLambdaIntegration("SendMessageIntegration", message_handler)
)
Parameters:
  • id (str) – id of the underlying integration construct.

  • handler (IFunction) – the Lambda function handler.

  • content_handling (Optional[ContentHandling]) – Specifies how to handle response payload content type conversions. Default: - The response payload will be passed through from the integration response to the route response or method response without modification.

  • timeout (Optional[Duration]) – The maximum amount of time an integration will run before it returns without a response. Must be between 50 milliseconds and 29 seconds. Default: Duration.seconds(29)

Methods

bind(*, route, scope)

Bind this integration to the route.

Parameters:
  • route (IWebSocketRoute) – The route to which this is being bound.

  • scope (Construct) – The current scope in which the bind is occurring. If the WebSocketRouteIntegration being bound creates additional constructs, this will be used as their parent scope.

Return type:

WebSocketRouteIntegrationConfig