I am going through the adding database to elastic beanstalk python documentation but following the steps leads to the following error
2023/05/07 14:06:36.847596 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr: error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
/bin/sh: line 1: mysql_config: command not found
/bin/sh: line 1: mariadb_config: command not found
/bin/sh: line 1: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup.py", line 15, in <module>
metadata, options = get_config()
^^^^^^^^^^^^
File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-install-7hpz1pvs/mysqlclient_f18de82744fa43e9b3b8706c3e581791/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
[end of output]
I did some digging and came to the conclusion that mysql or mariadb is not installed to the ec2 instance. So I started browsing the available packages for the Amazon Linux 2023 AMI since my ec2 is running that version and modified my config in .ebextensions
folder to look like this:
packages:
yum:
mysql-selinux: []
mariadb105: []
mariadb-connector-c: []
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
02_createsuperuser:
command: "source /var/app/venv/*/bin/activate && python3 manage.py createsuperuser --noinput --username aradipatrik2 --email [email protected]"
leader_only: true
03_save_data_to_db:
command: "source /var/app/venv/*/bin/activate && python3 manage.py save_data_to_db"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: env_info.settings
The packages install successfully but I still get the same exact error. When I ssh into the ec2 device to install mysql or mariadb manually the terminal tells me:
Changes made via SSH WILL BE LOST if the instance is replaced by auto-scaling
So my question is:
How can I install mysql or mariadb onto the ec2 instance when deploying the application using elastic beanstalk, so I can have mysqlclient==2.0.3
inside my requirements.txt
My requirements.txt
asgiref==3.6.0
branca==0.6.0
certifi==2022.12.7
charset-normalizer==3.1.0
Django==4.2.1
folium==0.14.0
idna==3.4
Jinja2==3.1.2
MarkupSafe==2.1.2
numpy==1.24.3
python-dotenv==1.0.0
requests==2.29.0
sqlparse==0.4.4
tzdata==2023.3
urllib3==1.26.15
mysqlclient==2.0.3
edit: Received feedback to install mariadb package with a name ending in -dev or -devel but there's no such package listed at the available packages list for the Amazon Linux 2023 AMI any further pointers would be appreciated!
After some trial and error I ended up modifying my config file to start with this, which solved my issue
packages:
yum:
mariadb105-devel: []
I found the package completely by chance. If someone know how to discover these for the future please do tell me