1
1
# template-serverless-lambda-python
2
2
This project contains isolated examples of AWS Lambda Services as well this provide
3
3
a stack example.
4
+ [ ![ linting: pylint] ( https://img.shields.io/badge/linting-pylint-yellowgreen )] ( https://github.com/PyCQA/pylint )
5
+ [ ![ PEP8] ( https://img.shields.io/badge/code%20style-pep8-orange.svg )] ( https://www.python.org/dev/peps/pep-0008/ )
6
+ [ ![ Quality Gate Status] ( https://sonarcloud.io/api/project_badges/measure?project=madeiramadeirabr_template-serverless-lambda-python&metric=alert_status )] ( https://sonarcloud.io/summary/new_code?id=madeiramadeirabr_template-serverless-lambda-python )
7
+ [ ![ Coverage] ( https://sonarcloud.io/api/project_badges/measure?project=madeiramadeirabr_template-serverless-lambda-python&metric=coverage )] ( https://sonarcloud.io/summary/new_code?id=madeiramadeirabr_template-serverless-lambda-python )
8
+ [ ![ Reliability Rating] ( https://sonarcloud.io/api/project_badges/measure?project=madeiramadeirabr_template-serverless-lambda-python&metric=reliability_rating )] ( https://sonarcloud.io/summary/new_code?id=madeiramadeirabr_template-serverless-lambda-python )
4
9
5
10
## Service Architecture
6
- Example of architecture of this project stack.
11
+ Diagrams with application usage of this architecture.
12
+
13
+ More details [ here] ( https://drive.google.com/file/d/112om-id0zfd8qGd0Q4kTaoIwIgwx6DGJ/view?usp=sharing ) .
14
+
15
+ ### Cloud Architecture
16
+ Example of the architecture running on AWS Cloud.
17
+
7
18
![ Service-Arch] ( docs/service-arch.png )
8
19
9
- ## Service Stack
10
- Example of components of the architecture of this project.
11
- ![ Service-Stack] ( docs/service-stack.png )
20
+ ### Docker Architecture
21
+ Example of the architecture running with docker.
22
+ ![ Docker-Service-Arch] ( docs/service-stack.png )
23
+
24
+ ## General Service Routes Architecture
25
+ Example of OpenApi documentation.
26
+ ![ Swagger] ( docs/swagger.png )
27
+
28
+ Route list:
29
+ ```
30
+ GET / - Root
31
+ GET /docs - Swagger docs
32
+ GET /alive - Health Check
33
+ GET /v1/event/<event_type> - Event List
34
+ POST /v1/event/<event_type> - Create Event
35
+ ```
36
+
37
+ # Prerequisites
38
+ - Python >=3.6
39
+ - docker
40
+ - docker-compose
41
+ - python-dotenv
42
+ - jsonformatter
43
+ - requests
44
+ - pytz
45
+ - redis
46
+ - pyyaml
47
+ - apispec
48
+ - marshmallow
49
+ - Flask
50
+
51
+ ## Features
52
+ - Docker-compose
53
+ - Localstack
54
+ - SQS Integration
55
+ - Flask
56
+ - MySQL
57
+ - Redis
12
58
13
59
## Build environment script workflow
14
60
Example of the workflow to create the environment.
15
- ![ Service-Stack ] ( docs/runenv-workflow.drawio.png )
61
+ ![ Runenv-Workflow ] ( docs/runenv-workflow.drawio.png )
16
62
17
63
## Single project examples
18
64
@@ -31,20 +77,42 @@ You can find complex examples:
31
77
* [ Lambda SNS] ( ./examples/lambda_sns )
32
78
* [ Lambda S3] ( ./examples/lambda_s3 )
33
79
80
+ ## Details about requirements files
81
+ ### requirements.txt
82
+ Collection of common application modules, light modules.
83
+
84
+ ### requirements-vendor.txt
85
+ Collection of specific application modules, heavy modules that can be converted to layers if necessary.
34
86
35
- ## Stack
36
- * AWS Lambda
37
- * Flask for APIs
38
- * Custom code based in AWS Chalice for SQS, SNS, S3 and CRON
87
+ ### requirements-tests.txt
88
+ Collection of specific test application modules.
39
89
40
- ## Prerequisites
41
- * Docker
42
- * Docker-compose
43
- * Python 3.x
44
90
45
91
## Installation
46
- ### Creating the virtual env
47
- To create the venv and install the modules execute:
92
+ ### Installing AWS CLI
93
+ Documentation:
94
+ https://docs.aws.amazon.com/pt_br/cli/latest/userguide/install-cliv2.html
95
+
96
+ Execute the follow command:
97
+ ``` bash
98
+ apt install python38-env
99
+ apt install awscli
100
+ apt install zip
101
+ app install pip
102
+ ```
103
+ Execute the follow command:
104
+ ``` bash
105
+ aws configure
106
+ ```
107
+
108
+ ### Installing python venv support
109
+ Execute the follow command:
110
+ ``` bash
111
+ apt install python38-env
112
+ ```
113
+
114
+ ### Running Locally
115
+ To create the ` venv ` and install the modules execute:
48
116
``` bash
49
117
./scripts/venv.sh
50
118
```
@@ -54,12 +122,64 @@ To execute the build:
54
122
``` bash
55
123
./scripts/runenv.sh --build
56
124
```
125
+
57
126
Execute the follow command:
58
127
``` bash
59
128
./scripts/runenv.sh
60
129
```
61
- ### Boot the resources
130
+
131
+ ### Recovering the environment in error cases
62
132
Execute the follow command:
63
133
``` bash
64
- ./scripts/boot .sh
134
+ ./scripts/fixenv .sh
65
135
```
136
+
137
+ ## Automation scripts information
138
+ Bellow we describe the usage of the automation scripts.
139
+ These kebab case scripts helps the developer in general tasks.
140
+
141
+ ### General scripts
142
+ Kebab case script to help the developer in general tasks.
143
+
144
+ | Script | Description | Context |
145
+ | -----------------------------| -----------------------------------------------------------------------------------| -------------------|
146
+ | autopep8.sh | Execute the code-lint for pep8 | Codelint |
147
+ | boot.sh | Boot the application during de container execution | Local boot |
148
+ | boot-db.sh | Boot the data for the database | Local boot |
149
+ | boot-queues.sh | Boot the queues of the application in the localstack | Local boot |
150
+ | boot-validate-connection.sh | Check if localstack is ready to connect | Local boot |
151
+ | clean-env.sh | Clean the ./vendor folder | Local install |
152
+ | fixenv.sh | In some cases where the network are deleted, you can fix the container references | Local install |
153
+ | install.sh | Script to install the dependencies | Local install |
154
+ | install-local.sh | Script to install the dependencies in the ./vendor folder | Local install |
155
+ | openapi.sh | Script to generate the openapi.yaml | CI/CD pipeline |
156
+ | preenv.sh | Script to execute the pre build commands | Local boot |
157
+ | pylint.sh | Script to execute the pylint analysis | Local development |
158
+ | runenv.sh | Script to start the project locally | Local development |
159
+ | testenv.sh | Script to run the environment with focus in the component tests | Local development |
160
+ | venv.sh | Script to install the dependencies in the venv folder | Local install |
161
+ | venv-exec.sh | Script to execute scripts to install content inside the venv | Local install |
162
+ | zip.sh | Generate a zip file with the application content | Other |
163
+
164
+ ### Docker scripts
165
+ Helper scripts to do tasks for docker context;
166
+ ### Flask scripts
167
+ Helper scripts to run flask locally, not inside a docker container;
168
+ ### Localstack scripts
169
+ Helper scripts to run commands over Localstack resources like S3, SQS, Lambda, etc;
170
+ ### Migrations scripts
171
+ Helper scripts to execute migrations;
172
+ ### OpenApi scripts
173
+ Helper scripts to generate openapi schemas and specifications;
174
+ ### Tests scripts
175
+ Helper scripts to execute tests and generate reports;
176
+
177
+ ## Samples
178
+ See the project samples in this folder [ here] ( samples ) .
179
+
180
+
181
+ ## License
182
+ See the license: [ LICENSE.md] ( LICENSE.md ) .
183
+
184
+ ## Contributions
185
+ * Anderson de Oliveira Contreira [ andersoncontreira] ( https://github.com/andersoncontreira )
0 commit comments