Skip to content

Commit 4d7374e

Browse files
authored
feat(apigatewayv2): AWS type websocket api integration in http api (#28718)
Currently, Amazon.CDK.AWS.Apigatewayv2 lacks support for AWS option as the [IntegrationType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-integration.html#cfn-apigatewayv2-integration-integrationtype) for WebSocket Apigateway. Added the capability that allows user to create a WebSocket Apigateway that calls directly other AWS services without a Lambda function middleware. Closes #27164. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1dc95ac commit 4d7374e

File tree

14 files changed

+1211
-1
lines changed

14 files changed

+1211
-1
lines changed

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

+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/apigatewayv2awsintegrationintegtestDefaultTestDeployAssert2B785EAB.template.json

+36
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/cdk.out

+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.js.snapshot/integ-aws-websocket-integration.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
{
2+
"Resources": {
3+
"MyTable794EDED1": {
4+
"Type": "AWS::DynamoDB::Table",
5+
"Properties": {
6+
"AttributeDefinitions": [
7+
{
8+
"AttributeName": "id",
9+
"AttributeType": "S"
10+
}
11+
],
12+
"BillingMode": "PAY_PER_REQUEST",
13+
"KeySchema": [
14+
{
15+
"AttributeName": "id",
16+
"KeyType": "HASH"
17+
}
18+
],
19+
"TableName": "MyTable"
20+
},
21+
"UpdateReplacePolicy": "Delete",
22+
"DeletionPolicy": "Delete"
23+
},
24+
"ApiGatewayRoleD2518903": {
25+
"Type": "AWS::IAM::Role",
26+
"Properties": {
27+
"AssumeRolePolicyDocument": {
28+
"Statement": [
29+
{
30+
"Action": "sts:AssumeRole",
31+
"Effect": "Allow",
32+
"Principal": {
33+
"Service": "apigateway.amazonaws.com"
34+
}
35+
}
36+
],
37+
"Version": "2012-10-17"
38+
},
39+
"ManagedPolicyArns": [
40+
{
41+
"Fn::Join": [
42+
"",
43+
[
44+
"arn:",
45+
{
46+
"Ref": "AWS::Partition"
47+
},
48+
":iam::aws:policy/AmazonDynamoDBFullAccess"
49+
]
50+
]
51+
}
52+
]
53+
}
54+
},
55+
"mywsapi32E6CE11": {
56+
"Type": "AWS::ApiGatewayV2::Api",
57+
"Properties": {
58+
"Name": "mywsapi",
59+
"ProtocolType": "WEBSOCKET",
60+
"RouteSelectionExpression": "$request.body.action"
61+
}
62+
},
63+
"mywsapidefaultRouteDefaultIntegrationFFCB3BA9": {
64+
"Type": "AWS::ApiGatewayV2::Integration",
65+
"Properties": {
66+
"ApiId": {
67+
"Ref": "mywsapi32E6CE11"
68+
},
69+
"IntegrationType": "MOCK",
70+
"IntegrationUri": ""
71+
}
72+
},
73+
"mywsapidefaultRouteE9382DF8": {
74+
"Type": "AWS::ApiGatewayV2::Route",
75+
"Properties": {
76+
"ApiId": {
77+
"Ref": "mywsapi32E6CE11"
78+
},
79+
"AuthorizationType": "NONE",
80+
"RouteKey": "$default",
81+
"Target": {
82+
"Fn::Join": [
83+
"",
84+
[
85+
"integrations/",
86+
{
87+
"Ref": "mywsapidefaultRouteDefaultIntegrationFFCB3BA9"
88+
}
89+
]
90+
]
91+
}
92+
}
93+
},
94+
"mywsapiconnectRouteDynamodbPutItem9E189A39": {
95+
"Type": "AWS::ApiGatewayV2::Integration",
96+
"Properties": {
97+
"ApiId": {
98+
"Ref": "mywsapi32E6CE11"
99+
},
100+
"CredentialsArn": {
101+
"Fn::GetAtt": [
102+
"ApiGatewayRoleD2518903",
103+
"Arn"
104+
]
105+
},
106+
"IntegrationMethod": "POST",
107+
"IntegrationType": "AWS",
108+
"IntegrationUri": {
109+
"Fn::Join": [
110+
"",
111+
[
112+
"arn:aws:apigateway:",
113+
{
114+
"Ref": "AWS::Region"
115+
},
116+
":dynamodb:action/PutItem"
117+
]
118+
]
119+
},
120+
"RequestTemplates": {
121+
"application/json": {
122+
"Fn::Join": [
123+
"",
124+
[
125+
"{\"TableName\":\"",
126+
{
127+
"Ref": "MyTable794EDED1"
128+
},
129+
"\",\"Item\":{\"id\":{\"S\":\"$context.requestId\"}}}"
130+
]
131+
]
132+
}
133+
}
134+
}
135+
},
136+
"mywsapiconnectRoute45A0ED6A": {
137+
"Type": "AWS::ApiGatewayV2::Route",
138+
"Properties": {
139+
"ApiId": {
140+
"Ref": "mywsapi32E6CE11"
141+
},
142+
"AuthorizationType": "NONE",
143+
"RouteKey": "$connect",
144+
"Target": {
145+
"Fn::Join": [
146+
"",
147+
[
148+
"integrations/",
149+
{
150+
"Ref": "mywsapiconnectRouteDynamodbPutItem9E189A39"
151+
}
152+
]
153+
]
154+
}
155+
}
156+
},
157+
"DevStage520A913F": {
158+
"Type": "AWS::ApiGatewayV2::Stage",
159+
"Properties": {
160+
"ApiId": {
161+
"Ref": "mywsapi32E6CE11"
162+
},
163+
"AutoDeploy": true,
164+
"StageName": "dev"
165+
}
166+
}
167+
},
168+
"Parameters": {
169+
"BootstrapVersion": {
170+
"Type": "AWS::SSM::Parameter::Value<String>",
171+
"Default": "/cdk-bootstrap/hnb659fds/version",
172+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
173+
}
174+
},
175+
"Rules": {
176+
"CheckBootstrapVersion": {
177+
"Assertions": [
178+
{
179+
"Assert": {
180+
"Fn::Not": [
181+
{
182+
"Fn::Contains": [
183+
[
184+
"1",
185+
"2",
186+
"3",
187+
"4",
188+
"5"
189+
],
190+
{
191+
"Ref": "BootstrapVersion"
192+
}
193+
]
194+
}
195+
]
196+
},
197+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
198+
}
199+
]
200+
}
201+
}
202+
}

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

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

0 commit comments

Comments
 (0)