lambda-api-decorators-cdk 0.2.3__py3-none-any.whl
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.
- lambda_api_decorators_cdk/__init__.py +5 -0
- lambda_api_decorators_cdk/api_type.py +8 -0
- lambda_api_decorators_cdk/ast_helper.py +361 -0
- lambda_api_decorators_cdk/lambda_api.py +85 -0
- lambda_api_decorators_cdk/lambda_api_config.py +151 -0
- lambda_api_decorators_cdk/resource_builder.py +794 -0
- lambda_api_decorators_cdk/source_layout.py +8 -0
- lambda_api_decorators_cdk-0.2.3.dist-info/METADATA +144 -0
- lambda_api_decorators_cdk-0.2.3.dist-info/RECORD +12 -0
- lambda_api_decorators_cdk-0.2.3.dist-info/WHEEL +5 -0
- lambda_api_decorators_cdk-0.2.3.dist-info/licenses/LICENSE +21 -0
- lambda_api_decorators_cdk-0.2.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lambda-api-decorators-cdk
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: AWS CDK integration for Lambda API Decorators. Generate AWS Lambda and API Gateway infrastructure from decorated Python handlers.
|
|
5
|
+
Author: Mateo Marcos, Emanuel Arguinarena, Lucas Picchi
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Lambda API Decorators CDK
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
Project-URL: Homepage, https://github.com/lambda-api-decorators/lambda-api-decorators-cdk
|
|
28
|
+
Project-URL: Repository, https://github.com/lambda-api-decorators/lambda-api-decorators-cdk
|
|
29
|
+
Project-URL: Bug Reports, https://github.com/lambda-api-decorators/lambda-api-decorators-cdk
|
|
30
|
+
Keywords: cdk,lambda,aws,api gateway,ast
|
|
31
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Framework :: AWS CDK :: 2
|
|
34
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
35
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Requires-Python: >=3.9
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Requires-Dist: aws-cdk.aws-lambda-python-alpha
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# Lambda API Decorators CDK
|
|
48
|
+
|
|
49
|
+
## A library for AWS API Gateway/Lambda Proxy Integration
|
|
50
|
+
|
|
51
|
+
Lambda API Decorators CDK allows simplified resource creation for AWS Lambda functions and Rest API resources by using decorators and setting a builder with default, common or custom values for IAM Roles, Runtimes, Timeouts, Layers, Environment values, etc. This project relies abstract syntactic trees (ast) to analyze the code of your lambda functions and generate infraestructure accordingly.
|
|
52
|
+
|
|
53
|
+
### Installation
|
|
54
|
+
|
|
55
|
+
`lambda_api_decorators_cdk` is available from PyPI as `lambda-api-decorators-cdk`:
|
|
56
|
+
|
|
57
|
+
pip install lambda-api-decorators-cdk
|
|
58
|
+
|
|
59
|
+
Installation of [lambda-api-decorators](https://pypi.org/project/lambda-api-decorators/) is also required as a dependency for your lambda functions, since it provides the definition of decorators used within this module.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Example
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import lambda_api_decorators_cdk
|
|
66
|
+
or
|
|
67
|
+
from lambda_api_decorators_cdk import ResourceBuilder
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Builder instance
|
|
71
|
+
|
|
72
|
+
You may define a builder using lambda_api_decorators_cdk's constructor `ResourceBuilder`. This method returns an instance of the class that will be used to configure and create your Lambda Functions. By default, no parameters are required to instantiate the object, but custom options may be passed in advanced use cases.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from lambda_api_decorators_cdk import ResourceBuilder
|
|
76
|
+
|
|
77
|
+
builder = ResourceBuilder()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Builder Configuration
|
|
81
|
+
|
|
82
|
+
If opted to, you can set default values for IAM Roles, Memory Size, Timeout, Runtime and VPC.
|
|
83
|
+
|
|
84
|
+
On the same note, support for common configuration that all the Lambda Functions will receive, such as Security Groups, Environment variables and Layers, is provided.
|
|
85
|
+
|
|
86
|
+
Lastly you can setup custom environments, layers, security groups, vpcs a Lambda Function will receive ONLY if they have the decorators defined.
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from lambda_api_decorators_cdk import ResourceBuilder
|
|
90
|
+
from aws_cdk import Duration
|
|
91
|
+
|
|
92
|
+
builder = ResourceBuilder()
|
|
93
|
+
builder.set_default_timeout(Duration.seconds(30))
|
|
94
|
+
builder.add_common_environment("DATABASE_URI", "something-db-related")
|
|
95
|
+
builder.add_custom_environment("URL-PREFIX", "lambda-api-decorators-cdk-") #Lambda Function should have decorator @environment("URL-PREFIX")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Building
|
|
99
|
+
|
|
100
|
+
Assuming you have already instantiated a Builder, configured it and ready to deploy your stack, then simply define the directory of your Lambda Functions and build!
|
|
101
|
+
|
|
102
|
+
Note: For a Lambda Function to be recognised and built, it has to have a decorator specifying the HTTP method it responds to. Decorators are defined in the [lambda-api-decorators](https://pypi.org/project/lambda-api-decorators/) package.
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
[...] # Imports
|
|
106
|
+
|
|
107
|
+
class LambdaApiDecoratorsExampleStack(Stack):
|
|
108
|
+
|
|
109
|
+
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
|
|
110
|
+
super().__init__(scope, construct_id, **kwargs)
|
|
111
|
+
|
|
112
|
+
[...] # Instantiating builder, defining options and layers...
|
|
113
|
+
|
|
114
|
+
lambda_path = 'lambdas'
|
|
115
|
+
|
|
116
|
+
restapi = apigateway.RestApi(
|
|
117
|
+
self, 'lambda-api-decorators-RestApi',
|
|
118
|
+
rest_api_name= 'lambda-api-decorators-restApi')
|
|
119
|
+
root_resource = restapi.root
|
|
120
|
+
|
|
121
|
+
builder.build(self, root_resource, lambda_path, print_tree=True)
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Maintainer releases
|
|
126
|
+
|
|
127
|
+
The Git tag is the single source of truth for this package's version. For
|
|
128
|
+
example, `v0.3.0` produces Python package version `0.3.0`. This repository is
|
|
129
|
+
versioned independently from `lambda-api-decorators`.
|
|
130
|
+
|
|
131
|
+
To release from `main`, choose and push a semantic version tag:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
git checkout main
|
|
135
|
+
git pull
|
|
136
|
+
|
|
137
|
+
git tag v0.3.0
|
|
138
|
+
git push origin v0.3.0
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Pushing the tag triggers the release workflow, which tests, builds, verifies
|
|
142
|
+
the version, and publishes with PyPI trusted publishing. The PyPI project must
|
|
143
|
+
have a trusted publisher configured for this repository, the `release.yml`
|
|
144
|
+
workflow, and the `pypi` GitHub environment.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
lambda_api_decorators_cdk/__init__.py,sha256=LkPu_ySBeRlGKVYbeLV86H78kYFrEQHBuzmskZo3nf8,197
|
|
2
|
+
lambda_api_decorators_cdk/api_type.py,sha256=UjhwP6KBwILl7NpL17e4mL-Bi5JdcfDs3oq2bxoESL0,146
|
|
3
|
+
lambda_api_decorators_cdk/ast_helper.py,sha256=zx1albQktG5D3Rlf5eXEJXiwoZsPF7qwEgTb_sATGEg,14978
|
|
4
|
+
lambda_api_decorators_cdk/lambda_api.py,sha256=wqiwe10-XOuPG8kxn2YGcpk4IHag1WG6mMHFENLgRhc,3148
|
|
5
|
+
lambda_api_decorators_cdk/lambda_api_config.py,sha256=Ngi0g-tN-M9ifv8xrX3UQqjA2RxtVmf6ejqhkYc2nNo,6103
|
|
6
|
+
lambda_api_decorators_cdk/resource_builder.py,sha256=IRYlILYasYywF1_kua-zNHYxG2jGJn4qF5QeAoJqFEQ,36350
|
|
7
|
+
lambda_api_decorators_cdk/source_layout.py,sha256=rvw2D0UTOyhHmiCg_NTuxFf2wvsFCBugnwNKd3NLWLo,167
|
|
8
|
+
lambda_api_decorators_cdk-0.2.3.dist-info/licenses/LICENSE,sha256=kABKIBEzZQqtNkBsAA9tA_Ume6OKdVUnChslMCL2Baw,1081
|
|
9
|
+
lambda_api_decorators_cdk-0.2.3.dist-info/METADATA,sha256=9vYl2q28NItUYeN16dmg4bzqKZgM1tF38KJ3Mf6DBq8,6434
|
|
10
|
+
lambda_api_decorators_cdk-0.2.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
11
|
+
lambda_api_decorators_cdk-0.2.3.dist-info/top_level.txt,sha256=1goCGc19BssxULn6ejZNLDYP0sQHEyqCMhivbGjxDCE,26
|
|
12
|
+
lambda_api_decorators_cdk-0.2.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Lambda API Decorators CDK
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lambda_api_decorators_cdk
|