Skip to content

Commit 7534dcd

Browse files
authored
feat(apigatewayv2): add missing WebSocketIntegration props (#29566)
### Issue # (if applicable) None as far as I can tell ### Reason for this change I was looking at the WebSocket integration to get a feel for #29562, and noticed a couple of missing properties ### Description of changes * Added support for `timeout` and `contentHandling` * Minor copy-pasta fixes in documentation and test description ### Description of how you validated changes I've added unit tests to check these optional properties. I've also updated and verified the following integrations tests: * `integ.lambda.ts`: * `ContentHandlingStrategy` and `TimeoutInMillis` are both correctly set ```sh $ aws apigatewayv2 get-integration --api-id bu24s9i8t0 --integration-id fxqec8c { "ConnectionType": "INTERNET", "ContentHandlingStrategy": "CONVERT_TO_TEXT", "IntegrationId": "fxqec8c", "IntegrationMethod": "POST", "IntegrationType": "AWS_PROXY", "IntegrationUri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:637423343434:function:WebSocketApiInteg-DefaultHandler604DF7AC-GSQYxsiaKjkz/invocations", "PassthroughBehavior": "WHEN_NO_MATCH", "PayloadFormatVersion": "1.0", "RequestTemplates": {}, "TimeoutInMillis": 10000 } ``` * `integ.aws.ts`: * `ContentHandlingStrategy`, `TemplateSelectionExpression`, `TimeoutInMillis`, `PassthroughBehavior`, and `RequestParameters` are all correctly set ```sh $ aws apigatewayv2 get-integration --api-id qp17tw07w3 --integration-id hycmjxb { "ConnectionType": "INTERNET", "ContentHandlingStrategy": "CONVERT_TO_BINARY", "CredentialsArn": "arn:aws:iam::637423343434:role/integ-aws-websocket-integrat-ApiGatewayRoleD2518903-i80lztfxo5XI", "IntegrationId": "hycmjxb", "IntegrationMethod": "POST", "IntegrationResponseSelectionExpression": "${integration.response.statuscode}", "IntegrationType": "AWS", "IntegrationUri": "arn:aws:apigateway:us-east-1:dynamodb:action/PutItem", "PassthroughBehavior": "WHEN_NO_TEMPLATES", "PayloadFormatVersion": "1.0", "RequestParameters": { "integration.request.header.Content-Type": "'application/x-www-form-urlencoded'" }, "RequestTemplates": { "application/json": "{\"TableName\":\"MyTable\",\"Item\":{\"id\":{\"S\":\"$context.requestId\"}}}" }, "TemplateSelectionExpression": "\\$default", "TimeoutInMillis": 10000 } ``` ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 3a78125 commit 7534dcd

File tree

18 files changed

+358
-184
lines changed

18 files changed

+358
-184
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.js.snapshot/integ-aws-websocket-integration.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.js.snapshot/integ-aws-websocket-integration.template.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"ApiId": {
9898
"Ref": "mywsapi32E6CE11"
9999
},
100+
"ContentHandlingStrategy": "CONVERT_TO_BINARY",
100101
"CredentialsArn": {
101102
"Fn::GetAtt": [
102103
"ApiGatewayRoleD2518903",
@@ -117,6 +118,10 @@
117118
]
118119
]
119120
},
121+
"PassthroughBehavior": "WHEN_NO_TEMPLATES",
122+
"RequestParameters": {
123+
"integration.request.header.Content-Type": "'application/x-www-form-urlencoded'"
124+
},
120125
"RequestTemplates": {
121126
"application/json": {
122127
"Fn::Join": [
@@ -130,7 +135,9 @@
130135
]
131136
]
132137
}
133-
}
138+
},
139+
"TemplateSelectionExpression": "\\$default",
140+
"TimeoutInMillis": 10000
134141
}
135142
},
136143
"mywsapiconnectRoute45A0ED6A": {

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.js.snapshot/manifest.json

+1-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.js.snapshot/tree.json

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.aws.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { HttpMethod, WebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
1+
import { ContentHandling, HttpMethod, PassthroughBehavior, WebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
22
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
33
import * as iam from 'aws-cdk-lib/aws-iam';
4-
import { App, RemovalPolicy, Stack } from 'aws-cdk-lib';
4+
import { App, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib';
55
import { WebSocketAwsIntegration, WebSocketMockIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
66
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
77

@@ -42,6 +42,9 @@ webSocketApi.addRoute('$connect', {
4242
integrationUri: `arn:aws:apigateway:${stack.region}:dynamodb:action/PutItem`,
4343
integrationMethod: HttpMethod.POST,
4444
credentialsRole: apiRole,
45+
requestParameters: {
46+
'integration.request.header.Content-Type': '\'application/x-www-form-urlencoded\'',
47+
},
4548
requestTemplates: {
4649
'application/json': JSON.stringify({
4750
TableName: table.tableName,
@@ -52,6 +55,10 @@ webSocketApi.addRoute('$connect', {
5255
},
5356
}),
5457
},
58+
templateSelectionExpression: '\\$default',
59+
passthroughBehavior: PassthroughBehavior.WHEN_NO_TEMPLATES,
60+
contentHandling: ContentHandling.CONVERT_TO_BINARY,
61+
timeout: Duration.seconds(10),
5562
}),
5663
});
5764

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.lambda.js.snapshot/WebSocketApiInteg.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.lambda.js.snapshot/WebSocketApiInteg.template.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@
431431
"ApiId": {
432432
"Ref": "mywsapi32E6CE11"
433433
},
434+
"ContentHandlingStrategy": "CONVERT_TO_TEXT",
434435
"IntegrationType": "AWS_PROXY",
435436
"IntegrationUri": {
436437
"Fn::Join": [
@@ -454,7 +455,8 @@
454455
"/invocations"
455456
]
456457
]
457-
}
458+
},
459+
"TimeoutInMillis": 10000
458460
}
459461
},
460462
"mywsapidefaultRouteE9382DF8": {

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.lambda.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.lambda.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigatewayv2-integrations/test/websocket/integ.lambda.js.snapshot/manifest.json

+6-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)