Template for build flexible SQS processor with AWS Lambda.
Diagrams with application usage of this architecture.
More details here.
Example of the architecture running on AWS Cloud.
Exemple of the architecture running with docker.

There are no routes for this project.
- Python >=3.6
- docker
- docker-compose
- python-dotenv
- jsonformatter
- requests
- pytz
- redis
- pyyaml
- apispec
- marshmallow
- Flask
- Docker-compose
- Localstack
- SQS Integration
- Flask
- MySQL
- Redis
Collection of common application modules, light modules.
Collection of specific application modules, heavy modules that can be converted to layers if necessary.
Collection of specific test application modules.
Documentation: https://docs.aws.amazon.com/pt_br/cli/latest/userguide/install-cliv2.html
Execute the follow command:
apt install python38-env
apt install awscli
apt install zip
app install pipExecute the follow command:
aws configureExecute the follow command:
apt install python38-envTo execute the creation of the Docker network, execute the follow command:
./scripts/docker/create-network.shTo create the venv and install the modules execute:
./scripts/venv.shThis mode provide an execution of Flask without the docker, but you will need to start any dependencies of the project by yourself.
Execute the follow command:
./scripts/flask/run-local.shTo do de fast development execute de follow commands.
To execute the build:
./scripts/dev.sh --buildExecute the follow command:
./scripts/dev.shTo simulate the lambda creating in the development environment execute the commands bellow.
To execute the build:
./scripts/runenv.sh --buildExecute the follow command:
./scripts/runenv.shExecute the follow command:
./scripts/fixenv.shBellow we describe the usage of the automation scripts. These kebab case scripts helps the developer in general tasks.
Kebab case script to help the developer in general tasks.
| Script | Description | Context |
|---|---|---|
| autopep8.sh | Execute the code-lint for pep8 | Codelint |
| boot.sh | Boot the application during de container execution | Local boot |
| boot-db.sh | Boot the data for the database | Local boot |
| boot-queues.sh | Boot the queues of the application in the localstack | Local boot |
| boot-validate-connection.sh | Check if localstack is ready to connect | Local boot |
| clean-env.sh | Clean the ./vendor folder | Local install |
| fixenv.sh | In some cases where the network are deleted, you can fix the container references | Local install |
| install.sh | Script to install the dependencies | Local install |
| install-local.sh | Script to install the dependencies in the ./vendor folder | Local install |
| openapi.sh | Script to generate the openapi.yaml | CI/CD pipeline |
| preenv.sh | Script to execute the pre build commands | Local boot |
| pylint.sh | Script to execute the pylint analysis | Local development |
| dev.sh | Script to start the project locally for development | Local development |
| runenv.sh | Script to start the project locally | Local development |
| testenv.sh | Script to run the environment with focus in the component tests | Local development |
| venv.sh | Script to install the dependencies in the venv folder | Local install |
| venv-exec.sh | Script to execute scripts to install content inside the venv | Local install |
| zip.sh | Generate a zip file with the application content | Other |
Helper scripts to do tasks for docker context;
Helper scripts to run flask locally, not inside a docker container;
Helper scripts to run commands over Localstack resources like S3, SQS, Lambda, etc;
Helper scripts to execute migrations;
Helper scripts to generate openapi schemas and specifications;
Helper scripts to execute tests and generate reports;
See the project samples in this folder here.
To run the unit tests of the project you can execute the follow command:
First you need install the tests requirements:
./scripts/venv-exec.sh ./scripts/tests/install-tests.sh Executing the tests:
./scripts/venv-exec.sh ./scripts/tests/unit-tests.shExecuting a specific file:
./scripts/venv-exec.sh ./scripts/tests/unit-tests.sh /tests/unit/test_app.pyStart the docker containers:
./scripts/testenv.shExecuting the tests:
./scripts/venv-exec.sh ./scripts/tests/component-tests.shExecuting a specific file:
./scripts/venv-exec.sh ./scripts/tests/component-tests.sh /tests/component/test_app.pyCopy the file env/integration.env.example to
env/integration.env and edit it with de staging parameters.
Executing the tests:
./scripts/venv-exec.sh ./scripts/tests/integration-tests.shExecuting a specific file:
./scripts/venv-exec.sh ./scripts/tests/integration-tests.sh /tests/integration/test_app.pyExecuting the tests:
./scripts/venv-exec.sh ./scripts/tests/tests.sh To execute coverage tests you can execute the follow commands:
Execute the follow command:
./scripts/venv-exec.sh ./scripts/tests/unit-coverage.shStart the docker containers:
./scripts/testenv.shExecute the follow command:
./scripts/venv-exec.sh ./scripts/tests/component-coverage.shCopy the file env/integration.env.example to
env/integration.env and edit it with de staging parameters.
Execute the follow command:
./scripts/venv-exec.sh ./scripts/tests/integration-coverage.shObservation:
The result can be found in the folder target/*.
See the license: LICENSE.md.
- Anderson de Oliveira Contreira andersoncontreira
- For docstring syntax please use the
reStructuredText - For line limit use 100 chars as defined by PEP8
To execute the pylint in the sourcecode of the project, execute the follow command:
./scripts/pylint.shOr:
./scripts/pylint.sh ./app.pyTo execute the autopep8 in the sourcecode of the project, execute the follow command:
./scripts/autopep8.shOr:
./scripts/autopep8.sh ./app.pyTo send a default event to SQS execute the follow command:
./scripts/localstack/sqs/send-message.shTo send a default payload to a specific queue, execute the follow command:
./scripts/localstack/sqs/send-message.sh test-queueTo send a specific payload, execute the follow command:
./scripts/localstack/sqs/send-message.sh test-queue '{
"chavenfe": "32210206107255000134550010001712551245826554",
"ocor": "MOTIVO DO CANCELAMENTO",
"origem": "SAC/EAGLE",
"pedido": "Z1223321"
}'To send a specific file payload, execute the follow command:
./scripts/localstack/sqs/send-message.sh test-queue ./samples/ocorens/cancelamento.json