WebSocketAwsIntegrationProps
- class aws_cdk.aws_apigatewayv2_integrations.WebSocketAwsIntegrationProps(*, integration_method, integration_uri, content_handling=None, credentials_role=None, passthrough_behavior=None, request_parameters=None, request_templates=None, template_selection_expression=None, timeout=None)
Bases:
object
Props for AWS type integration for a WebSocket Api.
- Parameters:
integration_method (
str
) – Specifies the integration’s HTTP method type.integration_uri (
str
) – Integration URI.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.credentials_role (
Optional
[IRole
]) – Specifies the credentials role required for the integration. Default: - No credential role provided.passthrough_behavior (
Optional
[PassthroughBehavior
]) – Specifies the pass-through behavior for incoming requests based on the Content-Type header in the request, and the available mapping templates specified as the requestTemplates property on the Integration resource. There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and NEVER. Default: - No passthrough behavior required.request_parameters (
Optional
[Mapping
[str
,str
]]) – The request parameters that API Gateway sends with the backend request. Specify request parameters as key-value pairs (string-to-string mappings), with a destination as the key and a source as the value. Default: - No request parameter provided to the integration.request_templates (
Optional
[Mapping
[str
,str
]]) – A map of Apache Velocity templates that are applied on the request payload. Example:: { “application/json”: “{ "statusCode": 200 }” } Default: - No request template provided to the integration.template_selection_expression (
Optional
[str
]) – The template selection expression for the integration. Default: - No template selection expression provided.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)
- ExampleMetadata:
infused
Example:
from aws_cdk.aws_apigatewayv2_integrations import WebSocketAwsIntegration import aws_cdk.aws_dynamodb as dynamodb import aws_cdk.aws_iam as iam # api_role: iam.Role # table: dynamodb.Table 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("$connect", integration=WebSocketAwsIntegration("DynamodbPutItem", integration_uri=f"arn:aws:apigateway:{this.region}:dynamodb:action/PutItem", integration_method=apigwv2.HttpMethod.POST, credentials_role=api_role, request_templates={ "application/json": JSON.stringify({ "TableName": table.table_name, "Item": { "id": { "S": "$context.requestId" } } }) } ) )
Attributes
- content_handling
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.
- credentials_role
Specifies the credentials role required for the integration.
- Default:
No credential role provided.
- integration_method
Specifies the integration’s HTTP method type.
- integration_uri
Integration URI.
- passthrough_behavior
Specifies the pass-through behavior for incoming requests based on the Content-Type header in the request, and the available mapping templates specified as the requestTemplates property on the Integration resource.
There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and NEVER.
- Default:
No passthrough behavior required.
- request_parameters
The request parameters that API Gateway sends with the backend request.
Specify request parameters as key-value pairs (string-to-string mappings), with a destination as the key and a source as the value.
- Default:
No request parameter provided to the integration.
- request_templates
A map of Apache Velocity templates that are applied on the request payload.
Example:
{ "application/json": "{ \"statusCode\": 200 }" }
- Default:
No request template provided to the integration.
- template_selection_expression
The template selection expression for the integration.
- Default:
No template selection expression provided.
- timeout
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)