WebSocketIntegration L2 construct
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 webSocketApiRef: apigatewayv2.IWebSocketApiRef;
const webSocketIntegration = new apigatewayv2.WebSocketIntegration(this, 'MyWebSocketIntegration', {
integrationType: apigatewayv2.WebSocketIntegrationType.AWS_PROXY,
integrationUri: 'integrationUri',
webSocketApi: webSocketApiRef,
// 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),
});
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_apigatewayv2 as apigatewayv2
from aws_cdk import aws_iam as iam
# role: iam.Role
# web_socket_api_ref: apigatewayv2.IWebSocketApiRef
web_socket_integration = apigatewayv2.WebSocketIntegration(self, "MyWebSocketIntegration",
integration_type=apigatewayv2.WebSocketIntegrationType.AWS_PROXY,
integration_uri="integrationUri",
web_socket_api=web_socket_api_ref,
# the properties below are optional
content_handling=apigatewayv2.ContentHandling.CONVERT_TO_BINARY,
credentials_role=role,
integration_method="integrationMethod",
passthrough_behavior=apigatewayv2.PassthroughBehavior.WHEN_NO_MATCH,
request_parameters={
"request_parameters_key": "requestParameters"
},
request_templates={
"request_templates_key": "requestTemplates"
},
template_selection_expression="templateSelectionExpression",
timeout=cdk.Duration.minutes(30)
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.apigatewayv2.*;
import software.amazon.awscdk.services.iam.*;
Role role;
IWebSocketApiRef webSocketApiRef;
WebSocketIntegration webSocketIntegration = WebSocketIntegration.Builder.create(this, "MyWebSocketIntegration")
.integrationType(WebSocketIntegrationType.AWS_PROXY)
.integrationUri("integrationUri")
.webSocketApi(webSocketApiRef)
// the properties below are optional
.contentHandling(ContentHandling.CONVERT_TO_BINARY)
.credentialsRole(role)
.integrationMethod("integrationMethod")
.passthroughBehavior(PassthroughBehavior.WHEN_NO_MATCH)
.requestParameters(Map.of(
"requestParametersKey", "requestParameters"))
.requestTemplates(Map.of(
"requestTemplatesKey", "requestTemplates"))
.templateSelectionExpression("templateSelectionExpression")
.timeout(Duration.minutes(30))
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.Apigatewayv2;
using Amazon.CDK.AWS.IAM;
Role role;
IWebSocketApiRef webSocketApiRef;
var webSocketIntegration = new WebSocketIntegration(this, "MyWebSocketIntegration", new WebSocketIntegrationProps {
IntegrationType = WebSocketIntegrationType.AWS_PROXY,
IntegrationUri = "integrationUri",
WebSocketApi = webSocketApiRef,
// the properties below are optional
ContentHandling = ContentHandling.CONVERT_TO_BINARY,
CredentialsRole = role,
IntegrationMethod = "integrationMethod",
PassthroughBehavior = PassthroughBehavior.WHEN_NO_MATCH,
RequestParameters = new Dictionary<string, string> {
{ "requestParametersKey", "requestParameters" }
},
RequestTemplates = new Dictionary<string, string> {
{ "requestTemplatesKey", "requestTemplates" }
},
TemplateSelectionExpression = "templateSelectionExpression",
Timeout = Duration.Minutes(30)
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var role Role
var webSocketApiRef IWebSocketApiRef
webSocketIntegration := awscdk.Aws_apigatewayv2.NewWebSocketIntegration(this, jsii.String("MyWebSocketIntegration"), &WebSocketIntegrationProps{
IntegrationType: awscdk.*Aws_apigatewayv2.WebSocketIntegrationType_AWS_PROXY,
IntegrationUri: jsii.String("integrationUri"),
WebSocketApi: webSocketApiRef,
// the properties below are optional
ContentHandling: awscdk.*Aws_apigatewayv2.ContentHandling_CONVERT_TO_BINARY,
CredentialsRole: role,
IntegrationMethod: jsii.String("integrationMethod"),
PassthroughBehavior: awscdk.*Aws_apigatewayv2.PassthroughBehavior_WHEN_NO_MATCH,
RequestParameters: map[string]*string{
"requestParametersKey": jsii.String("requestParameters"),
},
RequestTemplates: map[string]*string{
"requestTemplatesKey": jsii.String("requestTemplates"),
},
TemplateSelectionExpression: jsii.String("templateSelectionExpression"),
Timeout: cdk.Duration_Minutes(jsii.Number(30)),
})
Initializer
new WebSocketIntegration(scope: Construct, id: string, props: WebSocketIntegrationProps)
WebSocketIntegration(scope: Construct, id: str, props: WebSocketIntegrationProps)
new WebSocketIntegration(Construct scope, String id, WebSocketIntegrationProps props)
new WebSocketIntegration(Construct scope, string id, WebSocketIntegrationProps props)
NewWebSocketIntegration(Scope Construct, Id *string, Props WebSocketIntegrationProps)
Construct Props
contentHandlingoptionalContentHandlingcontent_handlingoptionalContentHandlingcontentHandlingoptionalContentHandlingContentHandlingoptionalContentHandlingContentHandlingoptionalContentHandling#Default: The response payload will be passed through from the integration response to the route response or method response without modification.
credentialsRoleoptionalIRolecredentials_roleoptionalIRolecredentialsRoleoptionalIRoleCredentialsRoleoptionalIRoleCredentialsRoleoptionalIRole#Default: No IAM role required.
integrationMethodoptionalstringintegration_methodoptionalstrintegrationMethodoptionalStringIntegrationMethodoptionalstringIntegrationMethodoptional*string#Default: No HTTP method required.
integrationTypeWebSocketIntegrationTypeintegration_typeWebSocketIntegrationTypeintegrationTypeWebSocketIntegrationTypeIntegrationTypeWebSocketIntegrationTypeIntegrationTypeWebSocketIntegrationTyperequired#integrationUristringintegration_uristrintegrationUriStringIntegrationUristringIntegrationUri*stringrequired#passthroughBehavioroptionalPassthroughBehaviorpassthrough_behavioroptionalPassthroughBehaviorpassthroughBehavioroptionalPassthroughBehaviorPassthroughBehavioroptionalPassthroughBehaviorPassthroughBehavioroptionalPassthroughBehavior#Default: No passthrough behavior required.
There are three valid values: WHEN_NO_MATCH, WHEN_NO_TEMPLATES, and NEVER.
requestParametersoptional{ [key: string]: string }request_parametersoptionaltyping.Mapping[str, str]requestParametersoptionalMap<String, String>RequestParametersoptionalIDictionary<string, string>RequestParametersoptional*map[string]*string#Default: No request parameters required.
Specify request parameters as key-value pairs (string-to-string mappings), with a destination as the key and a source as the value.
requestTemplatesoptional{ [key: string]: string }request_templatesoptionaltyping.Mapping[str, str]requestTemplatesoptionalMap<String, String>RequestTemplatesoptionalIDictionary<string, string>RequestTemplatesoptional*map[string]*string#Default: No request templates required.
{ "application/json": "{ \"statusCode\": 200 }" }
templateSelectionExpressionoptionalstringtemplate_selection_expressionoptionalstrtemplateSelectionExpressionoptionalStringTemplateSelectionExpressionoptionalstringTemplateSelectionExpressionoptional*string#Default: No template selection expression required.
timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration= Duration.seconds(29)#Must be between 50 milliseconds and 29 seconds.
webSocketApiIWebSocketApiRefweb_socket_apiIWebSocketApiRefwebSocketApiIWebSocketApiRefWebSocketApiIWebSocketApiRefWebSocketApiIWebSocketApiRefrequired#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
integrationIdstringintegration_idstrintegrationIdStringIntegrationIdstringIntegrationId*stringrequired#integrationRefIntegrationReferenceintegration_refIntegrationReferenceintegrationRefIntegrationReferenceIntegrationRefIntegrationReferenceIntegrationRefIntegrationReferencerequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#webSocketApiIWebSocketApiweb_socket_apiIWebSocketApiwebSocketApiIWebSocketApiWebSocketApiIWebSocketApiWebSocketApiIWebSocketApirequired#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.