class WebSocketIntegration (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Apigatewayv2.WebSocketIntegration |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigatewayv2#WebSocketIntegration |
Java | software.amazon.awscdk.services.apigatewayv2.WebSocketIntegration |
Python | aws_cdk.aws_apigatewayv2.WebSocketIntegration |
TypeScript (source) | aws-cdk-lib » aws_apigatewayv2 » WebSocketIntegration |
Implements
IConstruct
, IDependable
, IResource
, IWeb
, IIntegration
The integration for an API route.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_apigatewayv2 as apigatewayv2 } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
declare const role: iam.Role;
declare const webSocketApi: apigatewayv2.WebSocketApi;
const webSocketIntegration = new apigatewayv2.WebSocketIntegration(this, 'MyWebSocketIntegration', {
integrationType: apigatewayv2.WebSocketIntegrationType.AWS_PROXY,
integrationUri: 'integrationUri',
webSocketApi: webSocketApi,
// the properties below are optional
contentHandling: apigatewayv2.ContentHandling.CONVERT_TO_BINARY,
credentialsRole: role,
integrationMethod: 'integrationMethod',
passthroughBehavior: apigatewayv2.PassthroughBehavior.WHEN_NO_MATCH,
requestParameters: {
requestParametersKey: 'requestParameters',
},
requestTemplates: {
requestTemplatesKey: 'requestTemplates',
},
templateSelectionExpression: 'templateSelectionExpression',
timeout: cdk.Duration.minutes(30),
});
Initializer
new WebSocketIntegration(scope: Construct, id: string, props: WebSocketIntegrationProps)
Parameters
- scope
Construct
- id
string
- props
Web
Socket Integration Props
Construct Props
Name | Type | Description |
---|---|---|
integration | Web | Integration type. |
integration | string | Integration URI. |
web | IWeb | The WebSocket API to which this integration should be bound. |
content | Content | Specifies how to handle response payload content type conversions. |
credentials | IRole | Specifies the IAM role required for the integration. |
integration | string | Specifies the integration's HTTP method type. |
passthrough | Passthrough | 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. |
request | { [string]: string } | The request parameters that API Gateway sends with the backend request. |
request | { [string]: string } | A map of Apache Velocity templates that are applied on the request payload. |
template | string | The template selection expression for the integration. |
timeout? | Duration | The maximum amount of time an integration will run before it returns without a response. |
integrationType
Type:
Web
Integration type.
integrationUri
Type:
string
Integration URI.
webSocketApi
Type:
IWeb
The WebSocket API to which this integration should be bound.
contentHandling?
Type:
Content
(optional, default: The response payload will be passed through from the integration response to
the route response or method response without modification.)
Specifies how to handle response payload content type conversions.
credentialsRole?
Type:
IRole
(optional, default: No IAM role required.)
Specifies the IAM role required for the integration.
integrationMethod?
Type:
string
(optional, default: No HTTP method required.)
Specifies the integration's HTTP method type.
passthroughBehavior?
Type:
Passthrough
(optional, default: No passthrough behavior required.)
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.
requestParameters?
Type:
{ [string]: string }
(optional, default: No request parameters required.)
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.
requestTemplates?
Type:
{ [string]: string }
(optional, default: No request templates required.)
A map of Apache Velocity templates that are applied on the request payload.
{ "application/json": "{ \"statusCode\": 200 }" }
templateSelectionExpression?
Type:
string
(optional, default: No template selection expression required.)
The template selection expression for the integration.
timeout?
Type:
Duration
(optional, default: Duration.seconds(29))
The maximum amount of time an integration will run before it returns without a response.
Must be between 50 milliseconds and 29 seconds.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
integration | string | Id of the integration. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
web | IWeb | The WebSocket API associated with this integration. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
integrationId
Type:
string
Id of the integration.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
webSocketApi
Type:
IWeb
The WebSocket API associated with this integration.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.