Helper functions to run Django and Flask applications in AWS Copilot/ECS.
Maintained. Last release 9 months ago.
pip install dbt-copilot-pythonDBT Copilot Python
A set of utility functions for running Django & Flask apps in AWS ECS via AWS Copilot.
Using dbt-copilot-python
Supported Python versions
3.9, 3.10, 3.11, 3.12 and 3.13.
Installation
pip install dbt-copilot-python
With celery
If you are using celery, you should also install an appropriate version of celery using your project's package manager, or our built-in extra.
# Poetry
poetry add celery
# Pip
pip install celery
pip freeze | grep "^celery==" >> requirements.txt
# Pipenv
pipenv install celery
OR
# Poetry
poetry add dbt-copilot-python[celery]
# Pip
pip install dbt-copilot-python[celery]
pip freeze | grep "^celery==" >> requirements.txt
# Pipenv
pipenv install dbt-copilot-python[celery]
With error tracking
If you intend on using the error tracking filter, you should also install an appropriate version of ddtrace using your project's package manager, or our built-in extra.
# Poetry
poetry add ddtrace
# Pip
pip install ddtrace
pip freeze | grep "^ddtrace==" >> requirements.txt
# Pipenv
pipenv install ddtrace
OR
# Poetry
poetry add dbt-copilot-python[error-tracking]
# Pip
pip install dbt-copilot-python[error-tracking]
pip freeze | grep "^ddtrace==" >> requirements.txt
# Pipenv
pipenv install dbt-copilot-python[error-tracking]
Usage
ALLOWED_HOSTS setting
Add the ECS container IP to ALLOWED_HOSTS setting so that the Application Load Balancer (ALB) healthcheck will succeed:
from dbt_copilot_python.network import setup_allowed_hosts
ALLOWED_HOSTS = [...]
ALLOWED_HOSTS = setup_allowed_hosts(ALLOWED_HOSTS)
Celery health check
Install the library with celery.
Add the health check in your application's Celery config file...
from dbt_copilot_python.celery_health_check import healthcheck
celery_app = Celery("application_name")
...
celery_app = healthcheck.setup(celery_app)