aws-solutions-constructs.aws-apigatewayv2websocket-sqs 2.63.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/LICENSE +73 -0
  2. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/MANIFEST.in +1 -0
  3. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/PKG-INFO +171 -0
  4. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/README.md +149 -0
  5. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/pyproject.toml +9 -0
  6. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/setup.cfg +4 -0
  7. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/setup.py +66 -0
  8. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs/aws_apigatewayv2websocket_sqs/__init__.py +615 -0
  9. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs/aws_apigatewayv2websocket_sqs/_jsii/__init__.py +32 -0
  10. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs/aws_apigatewayv2websocket_sqs/_jsii/aws-apigatewayv2websocket-sqs@2.63.0.jsii.tgz +0 -0
  11. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs/aws_apigatewayv2websocket_sqs/py.typed +1 -0
  12. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs.aws_apigatewayv2websocket_sqs.egg-info/PKG-INFO +171 -0
  13. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs.aws_apigatewayv2websocket_sqs.egg-info/SOURCES.txt +14 -0
  14. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs.aws_apigatewayv2websocket_sqs.egg-info/dependency_links.txt +1 -0
  15. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs.aws_apigatewayv2websocket_sqs.egg-info/requires.txt +7 -0
  16. aws-solutions-constructs.aws-apigatewayv2websocket-sqs-2.63.0/src/aws_solutions_constructs.aws_apigatewayv2websocket_sqs.egg-info/top_level.txt +1 -0
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
@@ -0,0 +1 @@
1
+ include pyproject.toml
@@ -0,0 +1,171 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-apigatewayv2websocket-sqs
3
+ Version: 2.63.0
4
+ Summary: CDK constructs for defining an interaction between an AWS Lambda function and an Amazon S3 bucket.
5
+ Home-page: https://github.com/awslabs/aws-solutions-constructs.git
6
+ Author: Amazon Web Services
7
+ License: Apache-2.0
8
+ Project-URL: Source, https://github.com/awslabs/aws-solutions-constructs.git
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: JavaScript
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Typing :: Typed
18
+ Classifier: License :: OSI Approved
19
+ Requires-Python: ~=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+
23
+ # aws-apigatewayv2websocket-sqs module
24
+
25
+ <!--BEGIN STABILITY BANNER-->---
26
+
27
+
28
+ ![Stability: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)
29
+
30
+ ---
31
+ <!--END STABILITY BANNER-->
32
+
33
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
34
+ |:-------------|:-------------|
35
+
36
+ <div style="height:8px"></div>
37
+
38
+ | **Language** | **Package** |
39
+ |:-------------|-----------------|
40
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_apigatewayv2websocket_sqs`|
41
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-apigatewayv2websocket-sqs`|
42
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.apigatewayv2websocketsqs`|
43
+
44
+ ## Overview
45
+
46
+ This AWS Solutions Construct implements an Amazon API Gateway WebSocket connected to an Amazon SQS queue pattern.
47
+
48
+ Here is a minimal deployable pattern definition:
49
+
50
+ Typescript
51
+
52
+ ```python
53
+ import { Construct } from "constructs";
54
+ import { Stack, StackProps } from "aws-cdk-lib";
55
+ import {
56
+ ApiGatewayV2WebSocketToSqs,
57
+ ApiGatewayV2WebSocketToSqsProps,
58
+ } from "@aws-solutions-constructs/aws-apigatewayv2websocket-sqs";
59
+ import { WebSocketLambdaAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
60
+
61
+ const authorizer = new WebSocketLambdaAuthorizer('Authorizer', authHandler);
62
+
63
+ new ApiGateApiGatewayV2WebSocketToSqswayToSqs(this, "ApiGatewayV2WebSocketToSqsPattern", {
64
+ webSocketApiProps: {
65
+ connectRouteOptions: {
66
+ integration: new WebSocketLambdaIntegration("ConnectIntegration", connectLambda),
67
+ authorizer: authorizer,
68
+ },
69
+ disconnectRouteOptions: {
70
+ integration: new WebSocketLambdaIntegration("DisconnectIntegration", disconnectLambda),
71
+ },
72
+ },
73
+ createDefaultRoute: true
74
+ });
75
+ ```
76
+
77
+ Python
78
+
79
+ ```python
80
+ from aws_solutions_constructs.aws_apigateway_sqs import ApiGatewayV2WebSocketToSqs
81
+ from aws_cdk.aws_apigatewayv2_authorizers import WebSocketLambdaAuthorizer
82
+ from aws_cdk import Stack
83
+ from constructs import Construct
84
+
85
+ authorizer = WebSocketLambdaAuthorizer("Authorizer", auth_handler)
86
+
87
+ ApiGatewayV2WebSocketToSqs(self, 'ApiGatewayV2WebSocketToSqsPattern',
88
+ connect_route_options=apigwv2.WebSocketRouteOptions(
89
+ integration=WebSocketLambdaIntegration("ConnectIntegration", connect_lambda),
90
+ authorizer=authorizer
91
+ ),
92
+ disconnect_route_options=apigwv2.WebSocketRouteOptions(
93
+ integration=WebSocketLambdaIntegration("DisConnectIntegration", disconnect_lambda),
94
+ ),
95
+ create_default_route=True
96
+ )
97
+ ```
98
+
99
+ Java
100
+
101
+ ```java
102
+ import software.constructs.Construct;
103
+
104
+ import software.amazon.awscdk.Stack;
105
+ import software.amazon.awscdk.StackProps;
106
+ import software.amazon.awscdk.aws_apigatewayv2_authorizers.*;
107
+ import software.amazon.awscdk.aws_apigatewayv2_integrations.*;
108
+ import software.amazon.awsconstructs.services.apigatewaysqs.*;
109
+
110
+ new ApiGatewayV2WebSocketToSqs(this, "ApiGatewayV2WebSocketToSqsPattern", new ApiGatewayV2WebSocketToSqsProps.Builder()
111
+ .webSocketApiProps(new WebSocketApiProps.Builder()
112
+ .connectRouteOptions(new WebSocketRouteOptions.builder()
113
+ .integration(new WebSocketLambdaIntegration("ConnectIntegration", connect_lambda)))
114
+ .disconnectRouteOptions(new WebSocketRouteOptions.builder()
115
+ .integration(new WebSocketLambdaIntegration("DisConnectIntegration", disconnect_lambda)))
116
+ .createDefaultRoute(true)
117
+ .build());
118
+ ```
119
+
120
+ ## Pattern Construct Props
121
+
122
+ | **Name** | **Type** | **Description** |
123
+ |:-------------|:----------------|-----------------|
124
+ |existingWebSocketApi?|[`apigwv2.WebSocketApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApi.html)|Optional API Gateway WebSocket instance. Providing both existingWebSocketApi and webSocketApiProps will cause an error.|
125
+ |webSocketApiProps?|[`apigwv2.WebSocketApiProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiProps.html)|Optional user-provided props to override the default props for the API Gateway. Providing both existingWebSocketApi and webSocketApiProps will cause an error.|
126
+ |queueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.QueueProps.html)|Optional user-provided props to override the default props for the queue. Providing both existingQueueObj and queueProps will cause an error.|
127
+ |existingQueueObj?|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.Queue.html)|Optional existing instance of SQS Queue. Providing both existingQueueObj and queueProps will cause an error.|
128
+ |deployDeadLetterQueue?|`boolean`|Whether to deploy a secondary queue to be used as a dead letter queue. Defaults to `true`.|
129
+ |deadLetterQueueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.QueueProps.html)|Optional properties to use for creating dead letter queue. Note that if you are creating a FIFO Queue, the dead letter queue should also be FIFO.|
130
+ |maxReceiveCount|`number`|The number of times a message can be unsuccessfully dequeued before being moved to the dead-letter queue.|
131
+ |createDefaultRoute?|`boolean`|Whether to create a default route. At least one of createDefaultRoute or customRouteName must be provided. If set to true, then it will use the value supplied with `defaultRouteRequestTemplate`.|
132
+ |defaultRouteRequestTemplate?|`{ [contentType: string]: string }`|Optional user provided API Gateway Request Template for the default route and/ or customRoute (if customRouteName is provided). This property will only be used if createDefaultRoute is `true`. If createDefaultRoute is `true` and this property is not provided, the construct will create the default route with the following VTL mapping `"Action=SendMessage&MessageGroupId=$input.path('$.MessageGroupId')&MessageDeduplicationId=$context.requestId&MessageAttribute.1.Name=connectionId&MessageAttribute.1.Value.StringValue=$context.connectionId&MessageAttribute.1.Value.DataType=String&MessageAttribute.2.Name=requestId&MessageAttribute.2.Value.StringValue=$context.requestId&MessageAttribute.2.Value.DataType=String&MessageBody=$util.urlEncode($input.json($util.escapeJavaScript('$').replaceAll(\"\\\\'\",\"'\")))"`.|
133
+ |defaultIamAuthorization?|`boolean`|Add IAM authorization to the $connect path by default. Only set this to false if: 1) If plan to provide an authorizer with the `$connect` route; or 2) The API should be open (no authorization) (AWS recommends against deploying unprotected APIs). If an authorizer is specified in connectRouteOptions, this parameter is ignored and no default IAM authorizer will be created. |
134
+ |customRouteName?|`string`|The name of the route that will be sent through WebSocketApiProps.routeSelectionExpression when invoking the WebSocket endpoint. At least one of createDefaultRoute or customRouteName must be provided. |
135
+
136
+ ## Pattern Properties
137
+
138
+ | **Name** | **Type** | **Description** |
139
+ |:-------------|:----------------|-----------------|
140
+ |webSocketApi|[`apigwv2.WebSocketApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApi.html)|Returns an instance of the API Gateway WebSocket API created by the pattern.|
141
+ |apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
142
+ |webSocketStage|[`apigwv2.WebSocketStage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketStage.html)|Returns an instance of the WebSocketStage created by the construct.|
143
+ |apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
144
+ |sqsQueue|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.Queue.html)|Returns an instance of the SQS queue created by the pattern.|
145
+ |deadLetterQueue?|[`sqs.DeadLetterQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.DeadLetterQueue.html)|Returns an instance of the DeadLetterQueue created by the pattern.|
146
+
147
+ ## Default settings
148
+
149
+ Out of the box implementation of the Construct without any override will set the following defaults:
150
+
151
+ ### Amazon API Gateway
152
+
153
+ * Deploy a WebSocket endpoint
154
+ * Enable CloudWatch logging for API Gateway
155
+ * Configure least privilege access IAM role for API Gateway
156
+ * Enable X-Ray Tracing
157
+
158
+ ### Amazon SQS Queue
159
+
160
+ * Deploy SQS dead-letter queue for the source SQS Queue
161
+ * Enable server-side encryption for source SQS Queue using AWS Managed KMS Key
162
+ * Enforce encryption of data in transit
163
+
164
+ ## Architecture
165
+
166
+ ![Architecture Diagram](architecture.png)
167
+
168
+ ---
169
+
170
+
171
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,149 @@
1
+ # aws-apigatewayv2websocket-sqs module
2
+
3
+ <!--BEGIN STABILITY BANNER-->---
4
+
5
+
6
+ ![Stability: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)
7
+
8
+ ---
9
+ <!--END STABILITY BANNER-->
10
+
11
+ | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
12
+ |:-------------|:-------------|
13
+
14
+ <div style="height:8px"></div>
15
+
16
+ | **Language** | **Package** |
17
+ |:-------------|-----------------|
18
+ |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_apigatewayv2websocket_sqs`|
19
+ |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-apigatewayv2websocket-sqs`|
20
+ |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.apigatewayv2websocketsqs`|
21
+
22
+ ## Overview
23
+
24
+ This AWS Solutions Construct implements an Amazon API Gateway WebSocket connected to an Amazon SQS queue pattern.
25
+
26
+ Here is a minimal deployable pattern definition:
27
+
28
+ Typescript
29
+
30
+ ```python
31
+ import { Construct } from "constructs";
32
+ import { Stack, StackProps } from "aws-cdk-lib";
33
+ import {
34
+ ApiGatewayV2WebSocketToSqs,
35
+ ApiGatewayV2WebSocketToSqsProps,
36
+ } from "@aws-solutions-constructs/aws-apigatewayv2websocket-sqs";
37
+ import { WebSocketLambdaAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
38
+
39
+ const authorizer = new WebSocketLambdaAuthorizer('Authorizer', authHandler);
40
+
41
+ new ApiGateApiGatewayV2WebSocketToSqswayToSqs(this, "ApiGatewayV2WebSocketToSqsPattern", {
42
+ webSocketApiProps: {
43
+ connectRouteOptions: {
44
+ integration: new WebSocketLambdaIntegration("ConnectIntegration", connectLambda),
45
+ authorizer: authorizer,
46
+ },
47
+ disconnectRouteOptions: {
48
+ integration: new WebSocketLambdaIntegration("DisconnectIntegration", disconnectLambda),
49
+ },
50
+ },
51
+ createDefaultRoute: true
52
+ });
53
+ ```
54
+
55
+ Python
56
+
57
+ ```python
58
+ from aws_solutions_constructs.aws_apigateway_sqs import ApiGatewayV2WebSocketToSqs
59
+ from aws_cdk.aws_apigatewayv2_authorizers import WebSocketLambdaAuthorizer
60
+ from aws_cdk import Stack
61
+ from constructs import Construct
62
+
63
+ authorizer = WebSocketLambdaAuthorizer("Authorizer", auth_handler)
64
+
65
+ ApiGatewayV2WebSocketToSqs(self, 'ApiGatewayV2WebSocketToSqsPattern',
66
+ connect_route_options=apigwv2.WebSocketRouteOptions(
67
+ integration=WebSocketLambdaIntegration("ConnectIntegration", connect_lambda),
68
+ authorizer=authorizer
69
+ ),
70
+ disconnect_route_options=apigwv2.WebSocketRouteOptions(
71
+ integration=WebSocketLambdaIntegration("DisConnectIntegration", disconnect_lambda),
72
+ ),
73
+ create_default_route=True
74
+ )
75
+ ```
76
+
77
+ Java
78
+
79
+ ```java
80
+ import software.constructs.Construct;
81
+
82
+ import software.amazon.awscdk.Stack;
83
+ import software.amazon.awscdk.StackProps;
84
+ import software.amazon.awscdk.aws_apigatewayv2_authorizers.*;
85
+ import software.amazon.awscdk.aws_apigatewayv2_integrations.*;
86
+ import software.amazon.awsconstructs.services.apigatewaysqs.*;
87
+
88
+ new ApiGatewayV2WebSocketToSqs(this, "ApiGatewayV2WebSocketToSqsPattern", new ApiGatewayV2WebSocketToSqsProps.Builder()
89
+ .webSocketApiProps(new WebSocketApiProps.Builder()
90
+ .connectRouteOptions(new WebSocketRouteOptions.builder()
91
+ .integration(new WebSocketLambdaIntegration("ConnectIntegration", connect_lambda)))
92
+ .disconnectRouteOptions(new WebSocketRouteOptions.builder()
93
+ .integration(new WebSocketLambdaIntegration("DisConnectIntegration", disconnect_lambda)))
94
+ .createDefaultRoute(true)
95
+ .build());
96
+ ```
97
+
98
+ ## Pattern Construct Props
99
+
100
+ | **Name** | **Type** | **Description** |
101
+ |:-------------|:----------------|-----------------|
102
+ |existingWebSocketApi?|[`apigwv2.WebSocketApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApi.html)|Optional API Gateway WebSocket instance. Providing both existingWebSocketApi and webSocketApiProps will cause an error.|
103
+ |webSocketApiProps?|[`apigwv2.WebSocketApiProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiProps.html)|Optional user-provided props to override the default props for the API Gateway. Providing both existingWebSocketApi and webSocketApiProps will cause an error.|
104
+ |queueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.QueueProps.html)|Optional user-provided props to override the default props for the queue. Providing both existingQueueObj and queueProps will cause an error.|
105
+ |existingQueueObj?|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.Queue.html)|Optional existing instance of SQS Queue. Providing both existingQueueObj and queueProps will cause an error.|
106
+ |deployDeadLetterQueue?|`boolean`|Whether to deploy a secondary queue to be used as a dead letter queue. Defaults to `true`.|
107
+ |deadLetterQueueProps?|[`sqs.QueueProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.QueueProps.html)|Optional properties to use for creating dead letter queue. Note that if you are creating a FIFO Queue, the dead letter queue should also be FIFO.|
108
+ |maxReceiveCount|`number`|The number of times a message can be unsuccessfully dequeued before being moved to the dead-letter queue.|
109
+ |createDefaultRoute?|`boolean`|Whether to create a default route. At least one of createDefaultRoute or customRouteName must be provided. If set to true, then it will use the value supplied with `defaultRouteRequestTemplate`.|
110
+ |defaultRouteRequestTemplate?|`{ [contentType: string]: string }`|Optional user provided API Gateway Request Template for the default route and/ or customRoute (if customRouteName is provided). This property will only be used if createDefaultRoute is `true`. If createDefaultRoute is `true` and this property is not provided, the construct will create the default route with the following VTL mapping `"Action=SendMessage&MessageGroupId=$input.path('$.MessageGroupId')&MessageDeduplicationId=$context.requestId&MessageAttribute.1.Name=connectionId&MessageAttribute.1.Value.StringValue=$context.connectionId&MessageAttribute.1.Value.DataType=String&MessageAttribute.2.Name=requestId&MessageAttribute.2.Value.StringValue=$context.requestId&MessageAttribute.2.Value.DataType=String&MessageBody=$util.urlEncode($input.json($util.escapeJavaScript('$').replaceAll(\"\\\\'\",\"'\")))"`.|
111
+ |defaultIamAuthorization?|`boolean`|Add IAM authorization to the $connect path by default. Only set this to false if: 1) If plan to provide an authorizer with the `$connect` route; or 2) The API should be open (no authorization) (AWS recommends against deploying unprotected APIs). If an authorizer is specified in connectRouteOptions, this parameter is ignored and no default IAM authorizer will be created. |
112
+ |customRouteName?|`string`|The name of the route that will be sent through WebSocketApiProps.routeSelectionExpression when invoking the WebSocket endpoint. At least one of createDefaultRoute or customRouteName must be provided. |
113
+
114
+ ## Pattern Properties
115
+
116
+ | **Name** | **Type** | **Description** |
117
+ |:-------------|:----------------|-----------------|
118
+ |webSocketApi|[`apigwv2.WebSocketApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApi.html)|Returns an instance of the API Gateway WebSocket API created by the pattern.|
119
+ |apiGatewayRole|[`iam.Role`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.Role.html)|Returns an instance of the iam.Role created by the construct for API Gateway.|
120
+ |webSocketStage|[`apigwv2.WebSocketStage`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketStage.html)|Returns an instance of the WebSocketStage created by the construct.|
121
+ |apiGatewayLogGroup|[`logs.LogGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroup.html)|Returns an instance of the LogGroup created by the construct for API Gateway access logging to CloudWatch.|
122
+ |sqsQueue|[`sqs.Queue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.Queue.html)|Returns an instance of the SQS queue created by the pattern.|
123
+ |deadLetterQueue?|[`sqs.DeadLetterQueue`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.DeadLetterQueue.html)|Returns an instance of the DeadLetterQueue created by the pattern.|
124
+
125
+ ## Default settings
126
+
127
+ Out of the box implementation of the Construct without any override will set the following defaults:
128
+
129
+ ### Amazon API Gateway
130
+
131
+ * Deploy a WebSocket endpoint
132
+ * Enable CloudWatch logging for API Gateway
133
+ * Configure least privilege access IAM role for API Gateway
134
+ * Enable X-Ray Tracing
135
+
136
+ ### Amazon SQS Queue
137
+
138
+ * Deploy SQS dead-letter queue for the source SQS Queue
139
+ * Enable server-side encryption for source SQS Queue using AWS Managed KMS Key
140
+ * Enforce encryption of data in transit
141
+
142
+ ## Architecture
143
+
144
+ ![Architecture Diagram](architecture.png)
145
+
146
+ ---
147
+
148
+
149
+ © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -0,0 +1,9 @@
1
+ [build-system]
2
+ requires = ["setuptools~=67.3.2", "wheel~=0.42"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.pyright]
6
+ defineConstant = { DEBUG = true }
7
+ pythonVersion = "3.8"
8
+ pythonPlatform = "All"
9
+ reportSelfClsParameterName = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,66 @@
1
+ import json
2
+ import setuptools
3
+
4
+ kwargs = json.loads(
5
+ """
6
+ {
7
+ "name": "aws-solutions-constructs.aws-apigatewayv2websocket-sqs",
8
+ "version": "2.63.0",
9
+ "description": "CDK constructs for defining an interaction between an AWS Lambda function and an Amazon S3 bucket.",
10
+ "license": "Apache-2.0",
11
+ "url": "https://github.com/awslabs/aws-solutions-constructs.git",
12
+ "long_description_content_type": "text/markdown",
13
+ "author": "Amazon Web Services",
14
+ "bdist_wheel": {
15
+ "universal": true
16
+ },
17
+ "project_urls": {
18
+ "Source": "https://github.com/awslabs/aws-solutions-constructs.git"
19
+ },
20
+ "package_dir": {
21
+ "": "src"
22
+ },
23
+ "packages": [
24
+ "aws_solutions_constructs.aws_apigatewayv2websocket_sqs",
25
+ "aws_solutions_constructs.aws_apigatewayv2websocket_sqs._jsii"
26
+ ],
27
+ "package_data": {
28
+ "aws_solutions_constructs.aws_apigatewayv2websocket_sqs._jsii": [
29
+ "aws-apigatewayv2websocket-sqs@2.63.0.jsii.tgz"
30
+ ],
31
+ "aws_solutions_constructs.aws_apigatewayv2websocket_sqs": [
32
+ "py.typed"
33
+ ]
34
+ },
35
+ "python_requires": "~=3.8",
36
+ "install_requires": [
37
+ "aws-cdk-lib==2.149.0",
38
+ "aws-cdk.integ-tests-alpha==2.149.0.a0",
39
+ "aws-solutions-constructs.core==2.63.0",
40
+ "constructs>=10.0.0, <11.0.0",
41
+ "jsii>=1.101.0, <2.0.0",
42
+ "publication>=0.0.3",
43
+ "typeguard~=2.13.3"
44
+ ],
45
+ "classifiers": [
46
+ "Intended Audience :: Developers",
47
+ "Operating System :: OS Independent",
48
+ "Programming Language :: JavaScript",
49
+ "Programming Language :: Python :: 3 :: Only",
50
+ "Programming Language :: Python :: 3.8",
51
+ "Programming Language :: Python :: 3.9",
52
+ "Programming Language :: Python :: 3.10",
53
+ "Programming Language :: Python :: 3.11",
54
+ "Typing :: Typed",
55
+ "License :: OSI Approved"
56
+ ],
57
+ "scripts": []
58
+ }
59
+ """
60
+ )
61
+
62
+ with open("README.md", encoding="utf8") as fp:
63
+ kwargs["long_description"] = fp.read()
64
+
65
+
66
+ setuptools.setup(**kwargs)