aws-solutions-constructs.aws-openapigateway-lambda 2.85.2__tar.gz → 2.85.3__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 (20) hide show
  1. aws_solutions_constructs_aws_openapigateway_lambda-2.85.3/PKG-INFO +29 -0
  2. aws_solutions_constructs_aws_openapigateway_lambda-2.85.3/README.md +1 -0
  3. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/setup.py +4 -4
  4. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs/aws_openapigateway_lambda/__init__.py +1 -242
  5. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/__init__.py +2 -2
  6. aws_solutions_constructs_aws_openapigateway_lambda-2.85.3/src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/aws-openapigateway-lambda@2.85.3.jsii.tgz +0 -0
  7. aws_solutions_constructs_aws_openapigateway_lambda-2.85.3/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/PKG-INFO +29 -0
  8. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/SOURCES.txt +1 -1
  9. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/requires.txt +2 -2
  10. aws_solutions_constructs_aws_openapigateway_lambda-2.85.2/PKG-INFO +0 -270
  11. aws_solutions_constructs_aws_openapigateway_lambda-2.85.2/README.md +0 -242
  12. aws_solutions_constructs_aws_openapigateway_lambda-2.85.2/src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/aws-openapigateway-lambda@2.85.2.jsii.tgz +0 -0
  13. aws_solutions_constructs_aws_openapigateway_lambda-2.85.2/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/PKG-INFO +0 -270
  14. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/LICENSE +0 -0
  15. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/MANIFEST.in +0 -0
  16. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/pyproject.toml +0 -0
  17. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/setup.cfg +0 -0
  18. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs/aws_openapigateway_lambda/py.typed +0 -0
  19. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/dependency_links.txt +0 -0
  20. {aws_solutions_constructs_aws_openapigateway_lambda-2.85.2 → aws_solutions_constructs_aws_openapigateway_lambda-2.85.3}/src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/top_level.txt +0 -0
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-openapigateway-lambda
3
+ Version: 2.85.3
4
+ Summary: CDK constructs for defining an interaction between an OpenAPI-defined API Gateway and one or more Lambda functions.
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.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Typing :: Typed
17
+ Classifier: License :: OSI Approved
18
+ Requires-Python: ~=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: aws-cdk-lib<3.0.0,>=2.193.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.85.3
23
+ Requires-Dist: aws-solutions-constructs.resources==2.85.3
24
+ Requires-Dist: constructs<11.0.0,>=10.0.0
25
+ Requires-Dist: jsii<2.0.0,>=1.111.0
26
+ Requires-Dist: publication>=0.0.3
27
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
28
+
29
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-openapigateway-lambda/README.adoc)
@@ -0,0 +1 @@
1
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-openapigateway-lambda/README.adoc)
@@ -5,7 +5,7 @@ kwargs = json.loads(
5
5
  """
6
6
  {
7
7
  "name": "aws-solutions-constructs.aws-openapigateway-lambda",
8
- "version": "2.85.2",
8
+ "version": "2.85.3",
9
9
  "description": "CDK constructs for defining an interaction between an OpenAPI-defined API Gateway and one or more Lambda functions.",
10
10
  "license": "Apache-2.0",
11
11
  "url": "https://github.com/awslabs/aws-solutions-constructs.git",
@@ -26,7 +26,7 @@ kwargs = json.loads(
26
26
  ],
27
27
  "package_data": {
28
28
  "aws_solutions_constructs.aws_openapigateway_lambda._jsii": [
29
- "aws-openapigateway-lambda@2.85.2.jsii.tgz"
29
+ "aws-openapigateway-lambda@2.85.3.jsii.tgz"
30
30
  ],
31
31
  "aws_solutions_constructs.aws_openapigateway_lambda": [
32
32
  "py.typed"
@@ -35,8 +35,8 @@ kwargs = json.loads(
35
35
  "python_requires": "~=3.9",
36
36
  "install_requires": [
37
37
  "aws-cdk-lib>=2.193.0, <3.0.0",
38
- "aws-solutions-constructs.core==2.85.2",
39
- "aws-solutions-constructs.resources==2.85.2",
38
+ "aws-solutions-constructs.core==2.85.3",
39
+ "aws-solutions-constructs.resources==2.85.3",
40
40
  "constructs>=10.0.0, <11.0.0",
41
41
  "jsii>=1.111.0, <2.0.0",
42
42
  "publication>=0.0.3",
@@ -1,246 +1,5 @@
1
1
  r'''
2
- # aws-openapigateway-lambda module
3
-
4
- <!--BEGIN STABILITY BANNER-->---
5
-
6
-
7
- ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
8
-
9
- ---
10
- <!--END STABILITY BANNER-->
11
-
12
- | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
13
- |:-------------|:-------------|
14
-
15
- <div style="height:8px"></div>
16
-
17
- | **Language** | **Package** |
18
- |:-------------|-----------------|
19
- |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_openapigateway_lambda`|
20
- |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-openapigateway-lambda`|
21
- |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.openapigatewaylambda`|
22
-
23
- ## Overview
24
-
25
- This AWS Solutions Construct implements an Amazon API Gateway REST API defined by an OpenAPI specification file connected to an AWS Lambda function.
26
-
27
- Here is a minimal deployable pattern definition.
28
-
29
- **NOTE** The referenced `openapi/apiDefinition.yaml` openapi definition file and `messages-lambda` lambda package directory for the three code samples below can both be found under this constructs `test` folder (`<repository_root>/source/patterns/@aws-solutions-constructs/aws-openapigateway-lambda/test`)
30
-
31
- Typescript
32
-
33
- ```python
34
- import { Stack, StackProps } from 'aws-cdk-lib';
35
- import { Construct } from 'constructs';
36
- import { OpenApiGatewayToLambda } from '@aws-solutions-constructs/aws-openapigateway-lambda';
37
- import { Asset } from 'aws-cdk-lib/aws-s3-assets';
38
- import * as path from 'path';
39
- import * as lambda from 'aws-cdk-lib/aws-lambda';
40
-
41
- const apiDefinitionAsset = new Asset(this, 'ApiDefinitionAsset', {
42
- path: path.join(__dirname, 'openapi/apiDefinition.yaml')
43
- });
44
-
45
- new OpenApiGatewayToLambda(this, 'OpenApiGatewayToLambda', {
46
- apiDefinitionAsset,
47
- apiIntegrations: [
48
- {
49
- id: 'MessagesHandler',
50
- lambdaFunctionProps: {
51
- runtime: lambda.Runtime.NODEJS_20_X,
52
- handler: 'index.handler',
53
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
54
- }
55
- }
56
- ]
57
- });
58
- ```
59
-
60
- Python
61
-
62
- ```python
63
- from aws_cdk import (
64
- Stack,
65
- aws_s3_assets as s3_assets,
66
- aws_lambda as lambda_,
67
- )
68
- from constructs import Construct
69
- from aws_solutions_constructs.aws_openapigateway_lambda import OpenApiGatewayToLambda, ApiIntegration
70
-
71
- class TestStack(Stack):
72
-
73
- def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
74
- super().__init__(scope, construct_id, **kwargs)
75
-
76
- api_definition_asset = s3_assets.Asset(self, "ApiDefinitionAsset", path="./openapi/apiDefinition.yaml")
77
-
78
- api_integration = ApiIntegration(id="MessagesHandler", lambda_function_props={
79
- "runtime": lambda_.Runtime.NODEJS_20_X,
80
- "handler": "index.handler",
81
- "code": lambda_.Code.from_asset("./messages-lambda")
82
- })
83
-
84
- openapigateway_to_lambda = OpenApiGatewayToLambda(self,
85
- id="OpenApiGatewayToLambda",
86
- api_integrations=[api_integration],
87
- api_definition_asset=api_definition_asset
88
- )
89
- ```
90
-
91
- Java
92
-
93
- ```java
94
- import software.amazon.awscdk.services.lambda.Code;
95
- import software.amazon.awscdk.services.lambda.FunctionProps;
96
- import software.amazon.awscdk.services.s3.assets.Asset;
97
- import software.amazon.awscdk.services.s3.assets.AssetProps;
98
- import software.amazon.awsconstructs.services.openapigatewaylambda.ApiIntegration;
99
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambda;
100
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambdaProps;
101
- import software.constructs.Construct;
102
- import software.amazon.awscdk.Stack;
103
- import software.amazon.awscdk.StackProps;
104
-
105
- import java.util.Collections;
106
-
107
- import static software.amazon.awscdk.services.lambda.Runtime.NODEJS_20_X;
108
-
109
- final Asset apiDefinitionAsset = new Asset(this, "ApiDefinition", AssetProps.builder().path("openapi/apiDefinition.yaml").build());
110
-
111
- final ApiIntegration apiIntegration = ApiIntegration.builder()
112
- .id("MessagesHandler")
113
- .lambdaFunctionProps(new FunctionProps.Builder()
114
- .runtime(NODEJS_20_X)
115
- .code(Code.fromAsset("messages-lambda"))
116
- .handler("index.handler")
117
- .build())
118
- .build();
119
-
120
- new OpenApiGatewayToLambda(this, "OpenApiGatewayToLambda", OpenApiGatewayToLambdaProps.builder()
121
- .apiDefinitionAsset(apiDefinitionAsset)
122
- .apiIntegrations(Collections.singletonList(apiIntegration))
123
- .build());
124
- ```
125
-
126
- ## Pattern Construct Props
127
-
128
- | **Name** | **Type** | **Description** |
129
- |:-------------|:----------------|-----------------|
130
- |apiGatewayProps?|[`apigateway.RestApiBaseProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApiBaseProps.html)|Optional user-provided props to override the default props for the API.|
131
- |apiDefinitionBucket?|[`s3.IBucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)|S3 Bucket where the OpenAPI spec file is located. When specifying this property, `apiDefinitionKey` must also be specified.|
132
- |apiDefinitionKey?|`string`|S3 Object name of the OpenAPI spec file. When specifying this property, `apiDefinitionBucket` must also be specified.|
133
- |apiDefinitionAsset?|[`aws_s3_assets.Asset`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)|Local file asset of the OpenAPI spec file.|
134
- |apiDefinitionJson?|any|OpenAPI specification represented in a JSON object to be embedded in the CloudFormation template. IMPORTANT - Including the spec in the template introduces a risk of the template growing too big, but there are some use cases that require an embedded spec. Unless your use case explicitly requires an embedded spec you should pass your spec as an S3 asset.|
135
- |apiIntegrations|`ApiIntegration[]`|One or more key-value pairs that contain an id for the api integration and either an existing lambda function or an instance of the LambdaProps. Please see the `Overview of how the OpenAPI file transformation works` section below for more usage details.|
136
- |logGroupProps?|[`logs.LogGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroupProps.html)|User provided props to override the default props for for the CloudWatchLogs LogGroup.|
137
-
138
- ## Pattern Properties
139
-
140
- | **Name** | **Type** | **Description** |
141
- |:-------------|:----------------|-----------------|
142
- |apiLambdaFunctions|`ApiLambdaFunction[]`|Returns an array of ApiLambdaFunction objects, where each has an `id` of the `apiIntegration` and the corresponding `lambda.Function` that it maps to.|
143
- |apiGateway|[`api.SpecRestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.SpecRestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
144
- |apiGatewayCloudWatchRole?|[`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 for CloudWatch access.|
145
- |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.|
146
-
147
- ## Interfaces defined by this construct
148
-
149
- `ApiIntegration`
150
- Maps a Lambda function to the id string used as a placeholder in the OpenAPI spec. The type has a required property, `id`, and two optional properties `existingLambdaObj`, and `lambdaFunctionProps`. The `id` property is used to map the corresponding lambda function being defined with the placeholder string in the OpenAPI template file, and is not a CDK construct ID. Exactly one of `existingLambdaObj` or `lambdaFunctionProps` must be specified or the construct will throw an error. The `existingLambaObj` property will accept a lambda.Function object OR a lambda.Alias object. The property `ApiIntegrations` is an array of this interface and is a required property when launching this construct.
151
-
152
- `ApiLambdaFunction`
153
- This interface returns the Lambda objects used when launching the construct. The `id` property will always be set, if an existing function was provided in the props or this construct created a new Lambda function, then that function will be in the `lambdaFunction` property. If a Lambda Alias was provided in the props, then that value will be specified in the `functionAlias` property. At no time will `lambdaFunction` and `functionAlias` be set on the same ApiLambdaFunction object. The construct exposes an array of these objects as a property.
154
-
155
- ## Overview of how the OpenAPI file transformation works
156
-
157
- This construct automatically transforms an incoming OpenAPI Definition (residing locally or in S3) by auto-populating the `uri` fields of the `x-amazon-apigateway-integration` integrations with the resolved value of the backing lambda functions. It does so by allowing the user to specify the `apiIntegrations` property and then correlates it with the api definition.
158
-
159
- Looking at an example - a user creates an instantiation of `apiIntegrations` that specifies one integration named `MessagesHandler` that passes in a set of `lambda.FunctionProps` and a second integration named `PhotosHandler` that passes in an existing `lambda.Function`:
160
-
161
- ```python
162
- const apiIntegrations: ApiIntegration[] = [
163
- {
164
- id: 'MessagesHandler',
165
- lambdaFunctionProps: {
166
- runtime: lambda.Runtime.NODEJS_20_X,
167
- handler: 'index.handler',
168
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
169
- }
170
- },
171
- {
172
- id: 'PhotosHandler',
173
- existingLambdaObj: new lambda.Function(this, 'PhotosLambda', {
174
- runtime: lambda.Runtime.NODEJS_20_X,
175
- handler: 'index.handler',
176
- code: lambda.Code.fromAsset(`${__dirname}/photos-lambda`),
177
- })
178
- }
179
- ]
180
- ```
181
-
182
- And a corresponding api definition with `GET` and `POST` methods on a `/messages` resource and a `GET` method on a `/photos` resource.
183
-
184
- ```
185
- openapi: "3.0.1"
186
- info:
187
- title: "api"
188
- version: "2023-02-20T20:46:08Z"
189
- paths:
190
- /messages:
191
- get:
192
- x-amazon-apigateway-integration:
193
- httpMethod: "POST"
194
- uri: MessagesHandler
195
- passthroughBehavior: "when_no_match"
196
- type: "aws_proxy"
197
- post:
198
- x-amazon-apigateway-integration:
199
- httpMethod: "POST"
200
- uri: MessagesHandler
201
- passthroughBehavior: "when_no_match"
202
- type: "aws_proxy"
203
- /photos:
204
- get:
205
- x-amazon-apigateway-integration:
206
- httpMethod: "POST"
207
- uri: PhotosHandler
208
- passthroughBehavior: "when_no_match"
209
- type: "aws_proxy"
210
- ```
211
-
212
- When the construct is created or updated, it will overwrite the `MessagesHandler` string with the fully resolved lambda proxy uri of the `MessagesHandlerLambdaFunction`, e.g., `arn:${Aws.PARTITION}:apigateway:${Aws.REGION}:lambda:path/2015-03-31/functions/${messagesLambda.functionArn}/invocations`, and similarly for the `PhotosHandler` string and `PhotosHandlerLambdaFunction`, resulting in a valid OpenAPI spec file that is then passed to the `SpecRestApi` construct.
213
-
214
- For more information on specifying an API with OpenAPI, please see the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
215
-
216
- ## Default settings
217
-
218
- Out of the box implementation of the Construct without any override will set the following defaults:
219
-
220
- ### Amazon API Gateway
221
-
222
- * Deploy an edge-optimized API endpoint
223
- * Enable CloudWatch logging for API Gateway
224
- * Configure least privilege access IAM role for API Gateway
225
- * Enable X-Ray Tracing
226
-
227
- ### AWS Lambda Function
228
-
229
- * Configure limited privilege access IAM roles for Lambda functions
230
- * Enable reusing connections with Keep-Alive for NodeJs Lambda functions
231
- * Enable X-Ray Tracing
232
- * Set Environment Variables
233
-
234
- * AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)
235
-
236
- ## Architecture
237
-
238
- ![Architecture Diagram](architecture.png)
239
-
240
- ---
241
-
242
-
243
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-openapigateway-lambda/README.adoc)
244
3
  '''
245
4
  from pkgutil import extend_path
246
5
  __path__ = extend_path(__path__, __name__)
@@ -35,9 +35,9 @@ import constructs._jsii
35
35
 
36
36
  __jsii_assembly__ = jsii.JSIIAssembly.load(
37
37
  "@aws-solutions-constructs/aws-openapigateway-lambda",
38
- "2.85.2",
38
+ "2.85.3",
39
39
  __name__[0:-6],
40
- "aws-openapigateway-lambda@2.85.2.jsii.tgz",
40
+ "aws-openapigateway-lambda@2.85.3.jsii.tgz",
41
41
  )
42
42
 
43
43
  __all__ = [
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-solutions-constructs.aws-openapigateway-lambda
3
+ Version: 2.85.3
4
+ Summary: CDK constructs for defining an interaction between an OpenAPI-defined API Gateway and one or more Lambda functions.
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.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Typing :: Typed
17
+ Classifier: License :: OSI Approved
18
+ Requires-Python: ~=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: aws-cdk-lib<3.0.0,>=2.193.0
22
+ Requires-Dist: aws-solutions-constructs.core==2.85.3
23
+ Requires-Dist: aws-solutions-constructs.resources==2.85.3
24
+ Requires-Dist: constructs<11.0.0,>=10.0.0
25
+ Requires-Dist: jsii<2.0.0,>=1.111.0
26
+ Requires-Dist: publication>=0.0.3
27
+ Requires-Dist: typeguard<4.3.0,>=2.13.3
28
+
29
+ Documentation for this pattern can be found [here](https://github.com/awslabs/aws-solutions-constructs/blob/main/source/patterns/%40aws-solutions-constructs/aws-openapigateway-lambda/README.adoc)
@@ -11,4 +11,4 @@ src/aws_solutions_constructs.aws_openapigateway_lambda.egg-info/top_level.txt
11
11
  src/aws_solutions_constructs/aws_openapigateway_lambda/__init__.py
12
12
  src/aws_solutions_constructs/aws_openapigateway_lambda/py.typed
13
13
  src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/__init__.py
14
- src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/aws-openapigateway-lambda@2.85.2.jsii.tgz
14
+ src/aws_solutions_constructs/aws_openapigateway_lambda/_jsii/aws-openapigateway-lambda@2.85.3.jsii.tgz
@@ -1,6 +1,6 @@
1
1
  aws-cdk-lib<3.0.0,>=2.193.0
2
- aws-solutions-constructs.core==2.85.2
3
- aws-solutions-constructs.resources==2.85.2
2
+ aws-solutions-constructs.core==2.85.3
3
+ aws-solutions-constructs.resources==2.85.3
4
4
  constructs<11.0.0,>=10.0.0
5
5
  jsii<2.0.0,>=1.111.0
6
6
  publication>=0.0.3
@@ -1,270 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: aws-solutions-constructs.aws-openapigateway-lambda
3
- Version: 2.85.2
4
- Summary: CDK constructs for defining an interaction between an OpenAPI-defined API Gateway and one or more Lambda functions.
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.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Typing :: Typed
17
- Classifier: License :: OSI Approved
18
- Requires-Python: ~=3.9
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: aws-cdk-lib<3.0.0,>=2.193.0
22
- Requires-Dist: aws-solutions-constructs.core==2.85.2
23
- Requires-Dist: aws-solutions-constructs.resources==2.85.2
24
- Requires-Dist: constructs<11.0.0,>=10.0.0
25
- Requires-Dist: jsii<2.0.0,>=1.111.0
26
- Requires-Dist: publication>=0.0.3
27
- Requires-Dist: typeguard<4.3.0,>=2.13.3
28
-
29
- # aws-openapigateway-lambda module
30
-
31
- <!--BEGIN STABILITY BANNER-->---
32
-
33
-
34
- ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
35
-
36
- ---
37
- <!--END STABILITY BANNER-->
38
-
39
- | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
40
- |:-------------|:-------------|
41
-
42
- <div style="height:8px"></div>
43
-
44
- | **Language** | **Package** |
45
- |:-------------|-----------------|
46
- |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_openapigateway_lambda`|
47
- |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-openapigateway-lambda`|
48
- |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.openapigatewaylambda`|
49
-
50
- ## Overview
51
-
52
- This AWS Solutions Construct implements an Amazon API Gateway REST API defined by an OpenAPI specification file connected to an AWS Lambda function.
53
-
54
- Here is a minimal deployable pattern definition.
55
-
56
- **NOTE** The referenced `openapi/apiDefinition.yaml` openapi definition file and `messages-lambda` lambda package directory for the three code samples below can both be found under this constructs `test` folder (`<repository_root>/source/patterns/@aws-solutions-constructs/aws-openapigateway-lambda/test`)
57
-
58
- Typescript
59
-
60
- ```python
61
- import { Stack, StackProps } from 'aws-cdk-lib';
62
- import { Construct } from 'constructs';
63
- import { OpenApiGatewayToLambda } from '@aws-solutions-constructs/aws-openapigateway-lambda';
64
- import { Asset } from 'aws-cdk-lib/aws-s3-assets';
65
- import * as path from 'path';
66
- import * as lambda from 'aws-cdk-lib/aws-lambda';
67
-
68
- const apiDefinitionAsset = new Asset(this, 'ApiDefinitionAsset', {
69
- path: path.join(__dirname, 'openapi/apiDefinition.yaml')
70
- });
71
-
72
- new OpenApiGatewayToLambda(this, 'OpenApiGatewayToLambda', {
73
- apiDefinitionAsset,
74
- apiIntegrations: [
75
- {
76
- id: 'MessagesHandler',
77
- lambdaFunctionProps: {
78
- runtime: lambda.Runtime.NODEJS_20_X,
79
- handler: 'index.handler',
80
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
81
- }
82
- }
83
- ]
84
- });
85
- ```
86
-
87
- Python
88
-
89
- ```python
90
- from aws_cdk import (
91
- Stack,
92
- aws_s3_assets as s3_assets,
93
- aws_lambda as lambda_,
94
- )
95
- from constructs import Construct
96
- from aws_solutions_constructs.aws_openapigateway_lambda import OpenApiGatewayToLambda, ApiIntegration
97
-
98
- class TestStack(Stack):
99
-
100
- def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
101
- super().__init__(scope, construct_id, **kwargs)
102
-
103
- api_definition_asset = s3_assets.Asset(self, "ApiDefinitionAsset", path="./openapi/apiDefinition.yaml")
104
-
105
- api_integration = ApiIntegration(id="MessagesHandler", lambda_function_props={
106
- "runtime": lambda_.Runtime.NODEJS_20_X,
107
- "handler": "index.handler",
108
- "code": lambda_.Code.from_asset("./messages-lambda")
109
- })
110
-
111
- openapigateway_to_lambda = OpenApiGatewayToLambda(self,
112
- id="OpenApiGatewayToLambda",
113
- api_integrations=[api_integration],
114
- api_definition_asset=api_definition_asset
115
- )
116
- ```
117
-
118
- Java
119
-
120
- ```java
121
- import software.amazon.awscdk.services.lambda.Code;
122
- import software.amazon.awscdk.services.lambda.FunctionProps;
123
- import software.amazon.awscdk.services.s3.assets.Asset;
124
- import software.amazon.awscdk.services.s3.assets.AssetProps;
125
- import software.amazon.awsconstructs.services.openapigatewaylambda.ApiIntegration;
126
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambda;
127
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambdaProps;
128
- import software.constructs.Construct;
129
- import software.amazon.awscdk.Stack;
130
- import software.amazon.awscdk.StackProps;
131
-
132
- import java.util.Collections;
133
-
134
- import static software.amazon.awscdk.services.lambda.Runtime.NODEJS_20_X;
135
-
136
- final Asset apiDefinitionAsset = new Asset(this, "ApiDefinition", AssetProps.builder().path("openapi/apiDefinition.yaml").build());
137
-
138
- final ApiIntegration apiIntegration = ApiIntegration.builder()
139
- .id("MessagesHandler")
140
- .lambdaFunctionProps(new FunctionProps.Builder()
141
- .runtime(NODEJS_20_X)
142
- .code(Code.fromAsset("messages-lambda"))
143
- .handler("index.handler")
144
- .build())
145
- .build();
146
-
147
- new OpenApiGatewayToLambda(this, "OpenApiGatewayToLambda", OpenApiGatewayToLambdaProps.builder()
148
- .apiDefinitionAsset(apiDefinitionAsset)
149
- .apiIntegrations(Collections.singletonList(apiIntegration))
150
- .build());
151
- ```
152
-
153
- ## Pattern Construct Props
154
-
155
- | **Name** | **Type** | **Description** |
156
- |:-------------|:----------------|-----------------|
157
- |apiGatewayProps?|[`apigateway.RestApiBaseProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApiBaseProps.html)|Optional user-provided props to override the default props for the API.|
158
- |apiDefinitionBucket?|[`s3.IBucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)|S3 Bucket where the OpenAPI spec file is located. When specifying this property, `apiDefinitionKey` must also be specified.|
159
- |apiDefinitionKey?|`string`|S3 Object name of the OpenAPI spec file. When specifying this property, `apiDefinitionBucket` must also be specified.|
160
- |apiDefinitionAsset?|[`aws_s3_assets.Asset`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)|Local file asset of the OpenAPI spec file.|
161
- |apiDefinitionJson?|any|OpenAPI specification represented in a JSON object to be embedded in the CloudFormation template. IMPORTANT - Including the spec in the template introduces a risk of the template growing too big, but there are some use cases that require an embedded spec. Unless your use case explicitly requires an embedded spec you should pass your spec as an S3 asset.|
162
- |apiIntegrations|`ApiIntegration[]`|One or more key-value pairs that contain an id for the api integration and either an existing lambda function or an instance of the LambdaProps. Please see the `Overview of how the OpenAPI file transformation works` section below for more usage details.|
163
- |logGroupProps?|[`logs.LogGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroupProps.html)|User provided props to override the default props for for the CloudWatchLogs LogGroup.|
164
-
165
- ## Pattern Properties
166
-
167
- | **Name** | **Type** | **Description** |
168
- |:-------------|:----------------|-----------------|
169
- |apiLambdaFunctions|`ApiLambdaFunction[]`|Returns an array of ApiLambdaFunction objects, where each has an `id` of the `apiIntegration` and the corresponding `lambda.Function` that it maps to.|
170
- |apiGateway|[`api.SpecRestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.SpecRestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
171
- |apiGatewayCloudWatchRole?|[`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 for CloudWatch access.|
172
- |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.|
173
-
174
- ## Interfaces defined by this construct
175
-
176
- `ApiIntegration`
177
- Maps a Lambda function to the id string used as a placeholder in the OpenAPI spec. The type has a required property, `id`, and two optional properties `existingLambdaObj`, and `lambdaFunctionProps`. The `id` property is used to map the corresponding lambda function being defined with the placeholder string in the OpenAPI template file, and is not a CDK construct ID. Exactly one of `existingLambdaObj` or `lambdaFunctionProps` must be specified or the construct will throw an error. The `existingLambaObj` property will accept a lambda.Function object OR a lambda.Alias object. The property `ApiIntegrations` is an array of this interface and is a required property when launching this construct.
178
-
179
- `ApiLambdaFunction`
180
- This interface returns the Lambda objects used when launching the construct. The `id` property will always be set, if an existing function was provided in the props or this construct created a new Lambda function, then that function will be in the `lambdaFunction` property. If a Lambda Alias was provided in the props, then that value will be specified in the `functionAlias` property. At no time will `lambdaFunction` and `functionAlias` be set on the same ApiLambdaFunction object. The construct exposes an array of these objects as a property.
181
-
182
- ## Overview of how the OpenAPI file transformation works
183
-
184
- This construct automatically transforms an incoming OpenAPI Definition (residing locally or in S3) by auto-populating the `uri` fields of the `x-amazon-apigateway-integration` integrations with the resolved value of the backing lambda functions. It does so by allowing the user to specify the `apiIntegrations` property and then correlates it with the api definition.
185
-
186
- Looking at an example - a user creates an instantiation of `apiIntegrations` that specifies one integration named `MessagesHandler` that passes in a set of `lambda.FunctionProps` and a second integration named `PhotosHandler` that passes in an existing `lambda.Function`:
187
-
188
- ```python
189
- const apiIntegrations: ApiIntegration[] = [
190
- {
191
- id: 'MessagesHandler',
192
- lambdaFunctionProps: {
193
- runtime: lambda.Runtime.NODEJS_20_X,
194
- handler: 'index.handler',
195
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
196
- }
197
- },
198
- {
199
- id: 'PhotosHandler',
200
- existingLambdaObj: new lambda.Function(this, 'PhotosLambda', {
201
- runtime: lambda.Runtime.NODEJS_20_X,
202
- handler: 'index.handler',
203
- code: lambda.Code.fromAsset(`${__dirname}/photos-lambda`),
204
- })
205
- }
206
- ]
207
- ```
208
-
209
- And a corresponding api definition with `GET` and `POST` methods on a `/messages` resource and a `GET` method on a `/photos` resource.
210
-
211
- ```
212
- openapi: "3.0.1"
213
- info:
214
- title: "api"
215
- version: "2023-02-20T20:46:08Z"
216
- paths:
217
- /messages:
218
- get:
219
- x-amazon-apigateway-integration:
220
- httpMethod: "POST"
221
- uri: MessagesHandler
222
- passthroughBehavior: "when_no_match"
223
- type: "aws_proxy"
224
- post:
225
- x-amazon-apigateway-integration:
226
- httpMethod: "POST"
227
- uri: MessagesHandler
228
- passthroughBehavior: "when_no_match"
229
- type: "aws_proxy"
230
- /photos:
231
- get:
232
- x-amazon-apigateway-integration:
233
- httpMethod: "POST"
234
- uri: PhotosHandler
235
- passthroughBehavior: "when_no_match"
236
- type: "aws_proxy"
237
- ```
238
-
239
- When the construct is created or updated, it will overwrite the `MessagesHandler` string with the fully resolved lambda proxy uri of the `MessagesHandlerLambdaFunction`, e.g., `arn:${Aws.PARTITION}:apigateway:${Aws.REGION}:lambda:path/2015-03-31/functions/${messagesLambda.functionArn}/invocations`, and similarly for the `PhotosHandler` string and `PhotosHandlerLambdaFunction`, resulting in a valid OpenAPI spec file that is then passed to the `SpecRestApi` construct.
240
-
241
- For more information on specifying an API with OpenAPI, please see the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
242
-
243
- ## Default settings
244
-
245
- Out of the box implementation of the Construct without any override will set the following defaults:
246
-
247
- ### Amazon API Gateway
248
-
249
- * Deploy an edge-optimized API endpoint
250
- * Enable CloudWatch logging for API Gateway
251
- * Configure least privilege access IAM role for API Gateway
252
- * Enable X-Ray Tracing
253
-
254
- ### AWS Lambda Function
255
-
256
- * Configure limited privilege access IAM roles for Lambda functions
257
- * Enable reusing connections with Keep-Alive for NodeJs Lambda functions
258
- * Enable X-Ray Tracing
259
- * Set Environment Variables
260
-
261
- * AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)
262
-
263
- ## Architecture
264
-
265
- ![Architecture Diagram](architecture.png)
266
-
267
- ---
268
-
269
-
270
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1,242 +0,0 @@
1
- # aws-openapigateway-lambda module
2
-
3
- <!--BEGIN STABILITY BANNER-->---
4
-
5
-
6
- ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.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_openapigateway_lambda`|
19
- |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-openapigateway-lambda`|
20
- |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.openapigatewaylambda`|
21
-
22
- ## Overview
23
-
24
- This AWS Solutions Construct implements an Amazon API Gateway REST API defined by an OpenAPI specification file connected to an AWS Lambda function.
25
-
26
- Here is a minimal deployable pattern definition.
27
-
28
- **NOTE** The referenced `openapi/apiDefinition.yaml` openapi definition file and `messages-lambda` lambda package directory for the three code samples below can both be found under this constructs `test` folder (`<repository_root>/source/patterns/@aws-solutions-constructs/aws-openapigateway-lambda/test`)
29
-
30
- Typescript
31
-
32
- ```python
33
- import { Stack, StackProps } from 'aws-cdk-lib';
34
- import { Construct } from 'constructs';
35
- import { OpenApiGatewayToLambda } from '@aws-solutions-constructs/aws-openapigateway-lambda';
36
- import { Asset } from 'aws-cdk-lib/aws-s3-assets';
37
- import * as path from 'path';
38
- import * as lambda from 'aws-cdk-lib/aws-lambda';
39
-
40
- const apiDefinitionAsset = new Asset(this, 'ApiDefinitionAsset', {
41
- path: path.join(__dirname, 'openapi/apiDefinition.yaml')
42
- });
43
-
44
- new OpenApiGatewayToLambda(this, 'OpenApiGatewayToLambda', {
45
- apiDefinitionAsset,
46
- apiIntegrations: [
47
- {
48
- id: 'MessagesHandler',
49
- lambdaFunctionProps: {
50
- runtime: lambda.Runtime.NODEJS_20_X,
51
- handler: 'index.handler',
52
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
53
- }
54
- }
55
- ]
56
- });
57
- ```
58
-
59
- Python
60
-
61
- ```python
62
- from aws_cdk import (
63
- Stack,
64
- aws_s3_assets as s3_assets,
65
- aws_lambda as lambda_,
66
- )
67
- from constructs import Construct
68
- from aws_solutions_constructs.aws_openapigateway_lambda import OpenApiGatewayToLambda, ApiIntegration
69
-
70
- class TestStack(Stack):
71
-
72
- def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
73
- super().__init__(scope, construct_id, **kwargs)
74
-
75
- api_definition_asset = s3_assets.Asset(self, "ApiDefinitionAsset", path="./openapi/apiDefinition.yaml")
76
-
77
- api_integration = ApiIntegration(id="MessagesHandler", lambda_function_props={
78
- "runtime": lambda_.Runtime.NODEJS_20_X,
79
- "handler": "index.handler",
80
- "code": lambda_.Code.from_asset("./messages-lambda")
81
- })
82
-
83
- openapigateway_to_lambda = OpenApiGatewayToLambda(self,
84
- id="OpenApiGatewayToLambda",
85
- api_integrations=[api_integration],
86
- api_definition_asset=api_definition_asset
87
- )
88
- ```
89
-
90
- Java
91
-
92
- ```java
93
- import software.amazon.awscdk.services.lambda.Code;
94
- import software.amazon.awscdk.services.lambda.FunctionProps;
95
- import software.amazon.awscdk.services.s3.assets.Asset;
96
- import software.amazon.awscdk.services.s3.assets.AssetProps;
97
- import software.amazon.awsconstructs.services.openapigatewaylambda.ApiIntegration;
98
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambda;
99
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambdaProps;
100
- import software.constructs.Construct;
101
- import software.amazon.awscdk.Stack;
102
- import software.amazon.awscdk.StackProps;
103
-
104
- import java.util.Collections;
105
-
106
- import static software.amazon.awscdk.services.lambda.Runtime.NODEJS_20_X;
107
-
108
- final Asset apiDefinitionAsset = new Asset(this, "ApiDefinition", AssetProps.builder().path("openapi/apiDefinition.yaml").build());
109
-
110
- final ApiIntegration apiIntegration = ApiIntegration.builder()
111
- .id("MessagesHandler")
112
- .lambdaFunctionProps(new FunctionProps.Builder()
113
- .runtime(NODEJS_20_X)
114
- .code(Code.fromAsset("messages-lambda"))
115
- .handler("index.handler")
116
- .build())
117
- .build();
118
-
119
- new OpenApiGatewayToLambda(this, "OpenApiGatewayToLambda", OpenApiGatewayToLambdaProps.builder()
120
- .apiDefinitionAsset(apiDefinitionAsset)
121
- .apiIntegrations(Collections.singletonList(apiIntegration))
122
- .build());
123
- ```
124
-
125
- ## Pattern Construct Props
126
-
127
- | **Name** | **Type** | **Description** |
128
- |:-------------|:----------------|-----------------|
129
- |apiGatewayProps?|[`apigateway.RestApiBaseProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApiBaseProps.html)|Optional user-provided props to override the default props for the API.|
130
- |apiDefinitionBucket?|[`s3.IBucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)|S3 Bucket where the OpenAPI spec file is located. When specifying this property, `apiDefinitionKey` must also be specified.|
131
- |apiDefinitionKey?|`string`|S3 Object name of the OpenAPI spec file. When specifying this property, `apiDefinitionBucket` must also be specified.|
132
- |apiDefinitionAsset?|[`aws_s3_assets.Asset`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)|Local file asset of the OpenAPI spec file.|
133
- |apiDefinitionJson?|any|OpenAPI specification represented in a JSON object to be embedded in the CloudFormation template. IMPORTANT - Including the spec in the template introduces a risk of the template growing too big, but there are some use cases that require an embedded spec. Unless your use case explicitly requires an embedded spec you should pass your spec as an S3 asset.|
134
- |apiIntegrations|`ApiIntegration[]`|One or more key-value pairs that contain an id for the api integration and either an existing lambda function or an instance of the LambdaProps. Please see the `Overview of how the OpenAPI file transformation works` section below for more usage details.|
135
- |logGroupProps?|[`logs.LogGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroupProps.html)|User provided props to override the default props for for the CloudWatchLogs LogGroup.|
136
-
137
- ## Pattern Properties
138
-
139
- | **Name** | **Type** | **Description** |
140
- |:-------------|:----------------|-----------------|
141
- |apiLambdaFunctions|`ApiLambdaFunction[]`|Returns an array of ApiLambdaFunction objects, where each has an `id` of the `apiIntegration` and the corresponding `lambda.Function` that it maps to.|
142
- |apiGateway|[`api.SpecRestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.SpecRestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
143
- |apiGatewayCloudWatchRole?|[`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 for CloudWatch access.|
144
- |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.|
145
-
146
- ## Interfaces defined by this construct
147
-
148
- `ApiIntegration`
149
- Maps a Lambda function to the id string used as a placeholder in the OpenAPI spec. The type has a required property, `id`, and two optional properties `existingLambdaObj`, and `lambdaFunctionProps`. The `id` property is used to map the corresponding lambda function being defined with the placeholder string in the OpenAPI template file, and is not a CDK construct ID. Exactly one of `existingLambdaObj` or `lambdaFunctionProps` must be specified or the construct will throw an error. The `existingLambaObj` property will accept a lambda.Function object OR a lambda.Alias object. The property `ApiIntegrations` is an array of this interface and is a required property when launching this construct.
150
-
151
- `ApiLambdaFunction`
152
- This interface returns the Lambda objects used when launching the construct. The `id` property will always be set, if an existing function was provided in the props or this construct created a new Lambda function, then that function will be in the `lambdaFunction` property. If a Lambda Alias was provided in the props, then that value will be specified in the `functionAlias` property. At no time will `lambdaFunction` and `functionAlias` be set on the same ApiLambdaFunction object. The construct exposes an array of these objects as a property.
153
-
154
- ## Overview of how the OpenAPI file transformation works
155
-
156
- This construct automatically transforms an incoming OpenAPI Definition (residing locally or in S3) by auto-populating the `uri` fields of the `x-amazon-apigateway-integration` integrations with the resolved value of the backing lambda functions. It does so by allowing the user to specify the `apiIntegrations` property and then correlates it with the api definition.
157
-
158
- Looking at an example - a user creates an instantiation of `apiIntegrations` that specifies one integration named `MessagesHandler` that passes in a set of `lambda.FunctionProps` and a second integration named `PhotosHandler` that passes in an existing `lambda.Function`:
159
-
160
- ```python
161
- const apiIntegrations: ApiIntegration[] = [
162
- {
163
- id: 'MessagesHandler',
164
- lambdaFunctionProps: {
165
- runtime: lambda.Runtime.NODEJS_20_X,
166
- handler: 'index.handler',
167
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
168
- }
169
- },
170
- {
171
- id: 'PhotosHandler',
172
- existingLambdaObj: new lambda.Function(this, 'PhotosLambda', {
173
- runtime: lambda.Runtime.NODEJS_20_X,
174
- handler: 'index.handler',
175
- code: lambda.Code.fromAsset(`${__dirname}/photos-lambda`),
176
- })
177
- }
178
- ]
179
- ```
180
-
181
- And a corresponding api definition with `GET` and `POST` methods on a `/messages` resource and a `GET` method on a `/photos` resource.
182
-
183
- ```
184
- openapi: "3.0.1"
185
- info:
186
- title: "api"
187
- version: "2023-02-20T20:46:08Z"
188
- paths:
189
- /messages:
190
- get:
191
- x-amazon-apigateway-integration:
192
- httpMethod: "POST"
193
- uri: MessagesHandler
194
- passthroughBehavior: "when_no_match"
195
- type: "aws_proxy"
196
- post:
197
- x-amazon-apigateway-integration:
198
- httpMethod: "POST"
199
- uri: MessagesHandler
200
- passthroughBehavior: "when_no_match"
201
- type: "aws_proxy"
202
- /photos:
203
- get:
204
- x-amazon-apigateway-integration:
205
- httpMethod: "POST"
206
- uri: PhotosHandler
207
- passthroughBehavior: "when_no_match"
208
- type: "aws_proxy"
209
- ```
210
-
211
- When the construct is created or updated, it will overwrite the `MessagesHandler` string with the fully resolved lambda proxy uri of the `MessagesHandlerLambdaFunction`, e.g., `arn:${Aws.PARTITION}:apigateway:${Aws.REGION}:lambda:path/2015-03-31/functions/${messagesLambda.functionArn}/invocations`, and similarly for the `PhotosHandler` string and `PhotosHandlerLambdaFunction`, resulting in a valid OpenAPI spec file that is then passed to the `SpecRestApi` construct.
212
-
213
- For more information on specifying an API with OpenAPI, please see the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
214
-
215
- ## Default settings
216
-
217
- Out of the box implementation of the Construct without any override will set the following defaults:
218
-
219
- ### Amazon API Gateway
220
-
221
- * Deploy an edge-optimized API endpoint
222
- * Enable CloudWatch logging for API Gateway
223
- * Configure least privilege access IAM role for API Gateway
224
- * Enable X-Ray Tracing
225
-
226
- ### AWS Lambda Function
227
-
228
- * Configure limited privilege access IAM roles for Lambda functions
229
- * Enable reusing connections with Keep-Alive for NodeJs Lambda functions
230
- * Enable X-Ray Tracing
231
- * Set Environment Variables
232
-
233
- * AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)
234
-
235
- ## Architecture
236
-
237
- ![Architecture Diagram](architecture.png)
238
-
239
- ---
240
-
241
-
242
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -1,270 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: aws-solutions-constructs.aws-openapigateway-lambda
3
- Version: 2.85.2
4
- Summary: CDK constructs for defining an interaction between an OpenAPI-defined API Gateway and one or more Lambda functions.
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.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Typing :: Typed
17
- Classifier: License :: OSI Approved
18
- Requires-Python: ~=3.9
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
21
- Requires-Dist: aws-cdk-lib<3.0.0,>=2.193.0
22
- Requires-Dist: aws-solutions-constructs.core==2.85.2
23
- Requires-Dist: aws-solutions-constructs.resources==2.85.2
24
- Requires-Dist: constructs<11.0.0,>=10.0.0
25
- Requires-Dist: jsii<2.0.0,>=1.111.0
26
- Requires-Dist: publication>=0.0.3
27
- Requires-Dist: typeguard<4.3.0,>=2.13.3
28
-
29
- # aws-openapigateway-lambda module
30
-
31
- <!--BEGIN STABILITY BANNER-->---
32
-
33
-
34
- ![Stability: Experimental](https://img.shields.io/badge/stability-Experimental-important.svg?style=for-the-badge)
35
-
36
- ---
37
- <!--END STABILITY BANNER-->
38
-
39
- | **Reference Documentation**:| <span style="font-weight: normal">https://docs.aws.amazon.com/solutions/latest/constructs/</span>|
40
- |:-------------|:-------------|
41
-
42
- <div style="height:8px"></div>
43
-
44
- | **Language** | **Package** |
45
- |:-------------|-----------------|
46
- |![Python Logo](https://docs.aws.amazon.com/cdk/api/latest/img/python32.png) Python|`aws_solutions_constructs.aws_openapigateway_lambda`|
47
- |![Typescript Logo](https://docs.aws.amazon.com/cdk/api/latest/img/typescript32.png) Typescript|`@aws-solutions-constructs/aws-openapigateway-lambda`|
48
- |![Java Logo](https://docs.aws.amazon.com/cdk/api/latest/img/java32.png) Java|`software.amazon.awsconstructs.services.openapigatewaylambda`|
49
-
50
- ## Overview
51
-
52
- This AWS Solutions Construct implements an Amazon API Gateway REST API defined by an OpenAPI specification file connected to an AWS Lambda function.
53
-
54
- Here is a minimal deployable pattern definition.
55
-
56
- **NOTE** The referenced `openapi/apiDefinition.yaml` openapi definition file and `messages-lambda` lambda package directory for the three code samples below can both be found under this constructs `test` folder (`<repository_root>/source/patterns/@aws-solutions-constructs/aws-openapigateway-lambda/test`)
57
-
58
- Typescript
59
-
60
- ```python
61
- import { Stack, StackProps } from 'aws-cdk-lib';
62
- import { Construct } from 'constructs';
63
- import { OpenApiGatewayToLambda } from '@aws-solutions-constructs/aws-openapigateway-lambda';
64
- import { Asset } from 'aws-cdk-lib/aws-s3-assets';
65
- import * as path from 'path';
66
- import * as lambda from 'aws-cdk-lib/aws-lambda';
67
-
68
- const apiDefinitionAsset = new Asset(this, 'ApiDefinitionAsset', {
69
- path: path.join(__dirname, 'openapi/apiDefinition.yaml')
70
- });
71
-
72
- new OpenApiGatewayToLambda(this, 'OpenApiGatewayToLambda', {
73
- apiDefinitionAsset,
74
- apiIntegrations: [
75
- {
76
- id: 'MessagesHandler',
77
- lambdaFunctionProps: {
78
- runtime: lambda.Runtime.NODEJS_20_X,
79
- handler: 'index.handler',
80
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
81
- }
82
- }
83
- ]
84
- });
85
- ```
86
-
87
- Python
88
-
89
- ```python
90
- from aws_cdk import (
91
- Stack,
92
- aws_s3_assets as s3_assets,
93
- aws_lambda as lambda_,
94
- )
95
- from constructs import Construct
96
- from aws_solutions_constructs.aws_openapigateway_lambda import OpenApiGatewayToLambda, ApiIntegration
97
-
98
- class TestStack(Stack):
99
-
100
- def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
101
- super().__init__(scope, construct_id, **kwargs)
102
-
103
- api_definition_asset = s3_assets.Asset(self, "ApiDefinitionAsset", path="./openapi/apiDefinition.yaml")
104
-
105
- api_integration = ApiIntegration(id="MessagesHandler", lambda_function_props={
106
- "runtime": lambda_.Runtime.NODEJS_20_X,
107
- "handler": "index.handler",
108
- "code": lambda_.Code.from_asset("./messages-lambda")
109
- })
110
-
111
- openapigateway_to_lambda = OpenApiGatewayToLambda(self,
112
- id="OpenApiGatewayToLambda",
113
- api_integrations=[api_integration],
114
- api_definition_asset=api_definition_asset
115
- )
116
- ```
117
-
118
- Java
119
-
120
- ```java
121
- import software.amazon.awscdk.services.lambda.Code;
122
- import software.amazon.awscdk.services.lambda.FunctionProps;
123
- import software.amazon.awscdk.services.s3.assets.Asset;
124
- import software.amazon.awscdk.services.s3.assets.AssetProps;
125
- import software.amazon.awsconstructs.services.openapigatewaylambda.ApiIntegration;
126
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambda;
127
- import software.amazon.awsconstructs.services.openapigatewaylambda.OpenApiGatewayToLambdaProps;
128
- import software.constructs.Construct;
129
- import software.amazon.awscdk.Stack;
130
- import software.amazon.awscdk.StackProps;
131
-
132
- import java.util.Collections;
133
-
134
- import static software.amazon.awscdk.services.lambda.Runtime.NODEJS_20_X;
135
-
136
- final Asset apiDefinitionAsset = new Asset(this, "ApiDefinition", AssetProps.builder().path("openapi/apiDefinition.yaml").build());
137
-
138
- final ApiIntegration apiIntegration = ApiIntegration.builder()
139
- .id("MessagesHandler")
140
- .lambdaFunctionProps(new FunctionProps.Builder()
141
- .runtime(NODEJS_20_X)
142
- .code(Code.fromAsset("messages-lambda"))
143
- .handler("index.handler")
144
- .build())
145
- .build();
146
-
147
- new OpenApiGatewayToLambda(this, "OpenApiGatewayToLambda", OpenApiGatewayToLambdaProps.builder()
148
- .apiDefinitionAsset(apiDefinitionAsset)
149
- .apiIntegrations(Collections.singletonList(apiIntegration))
150
- .build());
151
- ```
152
-
153
- ## Pattern Construct Props
154
-
155
- | **Name** | **Type** | **Description** |
156
- |:-------------|:----------------|-----------------|
157
- |apiGatewayProps?|[`apigateway.RestApiBaseProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApiBaseProps.html)|Optional user-provided props to override the default props for the API.|
158
- |apiDefinitionBucket?|[`s3.IBucket`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html)|S3 Bucket where the OpenAPI spec file is located. When specifying this property, `apiDefinitionKey` must also be specified.|
159
- |apiDefinitionKey?|`string`|S3 Object name of the OpenAPI spec file. When specifying this property, `apiDefinitionBucket` must also be specified.|
160
- |apiDefinitionAsset?|[`aws_s3_assets.Asset`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)|Local file asset of the OpenAPI spec file.|
161
- |apiDefinitionJson?|any|OpenAPI specification represented in a JSON object to be embedded in the CloudFormation template. IMPORTANT - Including the spec in the template introduces a risk of the template growing too big, but there are some use cases that require an embedded spec. Unless your use case explicitly requires an embedded spec you should pass your spec as an S3 asset.|
162
- |apiIntegrations|`ApiIntegration[]`|One or more key-value pairs that contain an id for the api integration and either an existing lambda function or an instance of the LambdaProps. Please see the `Overview of how the OpenAPI file transformation works` section below for more usage details.|
163
- |logGroupProps?|[`logs.LogGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.LogGroupProps.html)|User provided props to override the default props for for the CloudWatchLogs LogGroup.|
164
-
165
- ## Pattern Properties
166
-
167
- | **Name** | **Type** | **Description** |
168
- |:-------------|:----------------|-----------------|
169
- |apiLambdaFunctions|`ApiLambdaFunction[]`|Returns an array of ApiLambdaFunction objects, where each has an `id` of the `apiIntegration` and the corresponding `lambda.Function` that it maps to.|
170
- |apiGateway|[`api.SpecRestApi`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.SpecRestApi.html)|Returns an instance of the API Gateway REST API created by the pattern.|
171
- |apiGatewayCloudWatchRole?|[`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 for CloudWatch access.|
172
- |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.|
173
-
174
- ## Interfaces defined by this construct
175
-
176
- `ApiIntegration`
177
- Maps a Lambda function to the id string used as a placeholder in the OpenAPI spec. The type has a required property, `id`, and two optional properties `existingLambdaObj`, and `lambdaFunctionProps`. The `id` property is used to map the corresponding lambda function being defined with the placeholder string in the OpenAPI template file, and is not a CDK construct ID. Exactly one of `existingLambdaObj` or `lambdaFunctionProps` must be specified or the construct will throw an error. The `existingLambaObj` property will accept a lambda.Function object OR a lambda.Alias object. The property `ApiIntegrations` is an array of this interface and is a required property when launching this construct.
178
-
179
- `ApiLambdaFunction`
180
- This interface returns the Lambda objects used when launching the construct. The `id` property will always be set, if an existing function was provided in the props or this construct created a new Lambda function, then that function will be in the `lambdaFunction` property. If a Lambda Alias was provided in the props, then that value will be specified in the `functionAlias` property. At no time will `lambdaFunction` and `functionAlias` be set on the same ApiLambdaFunction object. The construct exposes an array of these objects as a property.
181
-
182
- ## Overview of how the OpenAPI file transformation works
183
-
184
- This construct automatically transforms an incoming OpenAPI Definition (residing locally or in S3) by auto-populating the `uri` fields of the `x-amazon-apigateway-integration` integrations with the resolved value of the backing lambda functions. It does so by allowing the user to specify the `apiIntegrations` property and then correlates it with the api definition.
185
-
186
- Looking at an example - a user creates an instantiation of `apiIntegrations` that specifies one integration named `MessagesHandler` that passes in a set of `lambda.FunctionProps` and a second integration named `PhotosHandler` that passes in an existing `lambda.Function`:
187
-
188
- ```python
189
- const apiIntegrations: ApiIntegration[] = [
190
- {
191
- id: 'MessagesHandler',
192
- lambdaFunctionProps: {
193
- runtime: lambda.Runtime.NODEJS_20_X,
194
- handler: 'index.handler',
195
- code: lambda.Code.fromAsset(`${__dirname}/messages-lambda`),
196
- }
197
- },
198
- {
199
- id: 'PhotosHandler',
200
- existingLambdaObj: new lambda.Function(this, 'PhotosLambda', {
201
- runtime: lambda.Runtime.NODEJS_20_X,
202
- handler: 'index.handler',
203
- code: lambda.Code.fromAsset(`${__dirname}/photos-lambda`),
204
- })
205
- }
206
- ]
207
- ```
208
-
209
- And a corresponding api definition with `GET` and `POST` methods on a `/messages` resource and a `GET` method on a `/photos` resource.
210
-
211
- ```
212
- openapi: "3.0.1"
213
- info:
214
- title: "api"
215
- version: "2023-02-20T20:46:08Z"
216
- paths:
217
- /messages:
218
- get:
219
- x-amazon-apigateway-integration:
220
- httpMethod: "POST"
221
- uri: MessagesHandler
222
- passthroughBehavior: "when_no_match"
223
- type: "aws_proxy"
224
- post:
225
- x-amazon-apigateway-integration:
226
- httpMethod: "POST"
227
- uri: MessagesHandler
228
- passthroughBehavior: "when_no_match"
229
- type: "aws_proxy"
230
- /photos:
231
- get:
232
- x-amazon-apigateway-integration:
233
- httpMethod: "POST"
234
- uri: PhotosHandler
235
- passthroughBehavior: "when_no_match"
236
- type: "aws_proxy"
237
- ```
238
-
239
- When the construct is created or updated, it will overwrite the `MessagesHandler` string with the fully resolved lambda proxy uri of the `MessagesHandlerLambdaFunction`, e.g., `arn:${Aws.PARTITION}:apigateway:${Aws.REGION}:lambda:path/2015-03-31/functions/${messagesLambda.functionArn}/invocations`, and similarly for the `PhotosHandler` string and `PhotosHandlerLambdaFunction`, resulting in a valid OpenAPI spec file that is then passed to the `SpecRestApi` construct.
240
-
241
- For more information on specifying an API with OpenAPI, please see the [OpenAPI Specification](https://spec.openapis.org/oas/latest.html)
242
-
243
- ## Default settings
244
-
245
- Out of the box implementation of the Construct without any override will set the following defaults:
246
-
247
- ### Amazon API Gateway
248
-
249
- * Deploy an edge-optimized API endpoint
250
- * Enable CloudWatch logging for API Gateway
251
- * Configure least privilege access IAM role for API Gateway
252
- * Enable X-Ray Tracing
253
-
254
- ### AWS Lambda Function
255
-
256
- * Configure limited privilege access IAM roles for Lambda functions
257
- * Enable reusing connections with Keep-Alive for NodeJs Lambda functions
258
- * Enable X-Ray Tracing
259
- * Set Environment Variables
260
-
261
- * AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)
262
-
263
- ## Architecture
264
-
265
- ![Architecture Diagram](architecture.png)
266
-
267
- ---
268
-
269
-
270
- © Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.