Skip to content

Commit f8fe1d2

Browse files
authored
feat(apigatewayv2): allow websockets routes to return response to client (#22984)
This PR allows WebSocket routes to return a response to the client. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 53beeae commit f8fe1d2

14 files changed

+635
-1
lines changed

packages/@aws-cdk/aws-apigatewayv2-integrations/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"@aws-cdk/assertions": "0.0.0",
8282
"@aws-cdk/cdk-build-tools": "0.0.0",
8383
"@aws-cdk/integ-runner": "0.0.0",
84+
"@aws-cdk/integ-tests": "0.0.0",
8485
"@aws-cdk/pkglint": "0.0.0",
8586
"@types/jest": "^27.5.2"
8687
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "IntegDefaultTestDeployAssert4E6713E1.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"536558280cda4b74d67fdcdc23a22d0fb7b7e175f5bb56b260d43680056a3718": {
5+
"source": {
6+
"path": "aws-cdk-aws-apigatewayv2-websockets.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "536558280cda4b74d67fdcdc23a22d0fb7b7e175f5bb56b260d43680056a3718.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"Resources": {
3+
"MyWebsocketApiEBAC53DF": {
4+
"Type": "AWS::ApiGatewayV2::Api",
5+
"Properties": {
6+
"Name": "MyWebsocketApi",
7+
"ProtocolType": "WEBSOCKET",
8+
"RouteSelectionExpression": "$request.body.action"
9+
}
10+
},
11+
"MyWebsocketApitestRouteSendMessageIntegration526C7CB6": {
12+
"Type": "AWS::ApiGatewayV2::Integration",
13+
"Properties": {
14+
"ApiId": {
15+
"Ref": "MyWebsocketApiEBAC53DF"
16+
},
17+
"IntegrationType": "MOCK",
18+
"IntegrationUri": ""
19+
}
20+
},
21+
"MyWebsocketApitestRoute893E635A": {
22+
"Type": "AWS::ApiGatewayV2::Route",
23+
"Properties": {
24+
"ApiId": {
25+
"Ref": "MyWebsocketApiEBAC53DF"
26+
},
27+
"RouteKey": "test",
28+
"AuthorizationType": "NONE",
29+
"RouteResponseSelectionExpression": "$default",
30+
"Target": {
31+
"Fn::Join": [
32+
"",
33+
[
34+
"integrations/",
35+
{
36+
"Ref": "MyWebsocketApitestRouteSendMessageIntegration526C7CB6"
37+
}
38+
]
39+
]
40+
}
41+
}
42+
},
43+
"MyWebsocketApitestRouteResponse5A88D743": {
44+
"Type": "AWS::ApiGatewayV2::RouteResponse",
45+
"Properties": {
46+
"ApiId": {
47+
"Ref": "MyWebsocketApiEBAC53DF"
48+
},
49+
"RouteId": {
50+
"Ref": "MyWebsocketApitestRoute893E635A"
51+
},
52+
"RouteResponseKey": "$default"
53+
}
54+
}
55+
},
56+
"Parameters": {
57+
"BootstrapVersion": {
58+
"Type": "AWS::SSM::Parameter::Value<String>",
59+
"Default": "/cdk-bootstrap/hnb659fds/version",
60+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
61+
}
62+
},
63+
"Rules": {
64+
"CheckBootstrapVersion": {
65+
"Assertions": [
66+
{
67+
"Assert": {
68+
"Fn::Not": [
69+
{
70+
"Fn::Contains": [
71+
[
72+
"1",
73+
"2",
74+
"3",
75+
"4",
76+
"5"
77+
],
78+
{
79+
"Ref": "BootstrapVersion"
80+
}
81+
]
82+
}
83+
]
84+
},
85+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
86+
}
87+
]
88+
}
89+
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"21.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "21.0.0",
3+
"testCases": {
4+
"Integ/DefaultTest": {
5+
"stacks": [
6+
"aws-cdk-aws-apigatewayv2-websockets"
7+
],
8+
"assertionStack": "Integ/DefaultTest/DeployAssert",
9+
"assertionStackName": "IntegDefaultTestDeployAssert4E6713E1"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"version": "21.0.0",
3+
"artifacts": {
4+
"aws-cdk-aws-apigatewayv2-websockets.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "aws-cdk-aws-apigatewayv2-websockets.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"aws-cdk-aws-apigatewayv2-websockets": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "aws-cdk-aws-apigatewayv2-websockets.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/536558280cda4b74d67fdcdc23a22d0fb7b7e175f5bb56b260d43680056a3718.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"aws-cdk-aws-apigatewayv2-websockets.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"aws-cdk-aws-apigatewayv2-websockets.assets"
34+
],
35+
"metadata": {
36+
"/aws-cdk-aws-apigatewayv2-websockets/MyWebsocketApi/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "MyWebsocketApiEBAC53DF"
40+
}
41+
],
42+
"/aws-cdk-aws-apigatewayv2-websockets/MyWebsocketApi/test-Route/SendMessageIntegration/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "MyWebsocketApitestRouteSendMessageIntegration526C7CB6"
46+
}
47+
],
48+
"/aws-cdk-aws-apigatewayv2-websockets/MyWebsocketApi/test-Route/Resource": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "MyWebsocketApitestRoute893E635A"
52+
}
53+
],
54+
"/aws-cdk-aws-apigatewayv2-websockets/MyWebsocketApi/test-Route/Response": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "MyWebsocketApitestRouteResponse5A88D743"
58+
}
59+
],
60+
"/aws-cdk-aws-apigatewayv2-websockets/BootstrapVersion": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "BootstrapVersion"
64+
}
65+
],
66+
"/aws-cdk-aws-apigatewayv2-websockets/CheckBootstrapVersion": [
67+
{
68+
"type": "aws:cdk:logicalId",
69+
"data": "CheckBootstrapVersion"
70+
}
71+
]
72+
},
73+
"displayName": "aws-cdk-aws-apigatewayv2-websockets"
74+
},
75+
"IntegDefaultTestDeployAssert4E6713E1.assets": {
76+
"type": "cdk:asset-manifest",
77+
"properties": {
78+
"file": "IntegDefaultTestDeployAssert4E6713E1.assets.json",
79+
"requiresBootstrapStackVersion": 6,
80+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
81+
}
82+
},
83+
"IntegDefaultTestDeployAssert4E6713E1": {
84+
"type": "aws:cloudformation:stack",
85+
"environment": "aws://unknown-account/unknown-region",
86+
"properties": {
87+
"templateFile": "IntegDefaultTestDeployAssert4E6713E1.template.json",
88+
"validateOnSynth": false,
89+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
90+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
91+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
92+
"requiresBootstrapStackVersion": 6,
93+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
94+
"additionalDependencies": [
95+
"IntegDefaultTestDeployAssert4E6713E1.assets"
96+
],
97+
"lookupRole": {
98+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
99+
"requiresBootstrapStackVersion": 8,
100+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
101+
}
102+
},
103+
"dependencies": [
104+
"IntegDefaultTestDeployAssert4E6713E1.assets"
105+
],
106+
"metadata": {
107+
"/Integ/DefaultTest/DeployAssert/BootstrapVersion": [
108+
{
109+
"type": "aws:cdk:logicalId",
110+
"data": "BootstrapVersion"
111+
}
112+
],
113+
"/Integ/DefaultTest/DeployAssert/CheckBootstrapVersion": [
114+
{
115+
"type": "aws:cdk:logicalId",
116+
"data": "CheckBootstrapVersion"
117+
}
118+
]
119+
},
120+
"displayName": "Integ/DefaultTest/DeployAssert"
121+
},
122+
"Tree": {
123+
"type": "cdk:tree",
124+
"properties": {
125+
"file": "tree.json"
126+
}
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)