22

I am deploying a django with mysql app on AWS Elastic Beanstalk, so mysqlclient library is needed. mysqlclient needs python3-devel and mysql-devel package to be installed, so I have the custom config file for it 01_packages.config:

packages: 
  yum:
    python3-devel: []
    mysql-devel: []

Deployment fails and the log file /var/log/cfn-init.log (mentioned in Beanstalk logs) shows the error:

2020-05-31 02:17:37,565 [INFO] -----------------------Starting build-----------------------
2020-05-31 02:17:37,572 [INFO] Running configSets: Infra-EmbeddedPreBuild
2020-05-31 02:17:37,575 [INFO] Running configSet Infra-EmbeddedPreBuild
2020-05-31 02:17:37,579 [INFO] Running config prebuild_0_doyouknow
2020-05-31 02:17:41,831 [ERROR] mysql-devel is not available to be installed
2020-05-31 02:17:41,831 [ERROR] Error encountered during build of prebuild_0_doyouknow: Yum does no
t have mysql-devel available for installation
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config
    CloudFormationCarpenter(config, self._auth_config).build(worklog)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 229, in build
    changes['packages'][manager] = CloudFormationCarpenter._packageTools[manager]().apply(packages,
 self._auth_config)
  File "/usr/lib/python2.7/site-packages/cfnbootstrap/rpm_tools.py", line 74, in apply
    raise ToolError("Yum does not have %s available for installation" % pkg_spec)
ToolError: Yum does not have mysql-devel available for installation
2020-05-31 02:17:41,834 [ERROR] -----------------------BUILD FAILED!------------------------

However, I tried to install it manually on my Ec2 instance through yum install mysql-devel and it is installed successfully.

My python version is 3.7 and my requirements.txt file content is:

asgiref==3.2.7
Django==3.0.5
django-cors-headers==3.2.1
django-dotenv==1.4.2
django-social-share==1.4.0
mysqlclient==1.4.6
numpy==1.18.4
pandas==1.0.3
Pillow==7.1.1
python-dateutil==2.8.1
pytz==2019.3
six==1.14.0
sqlparse==0.3.1
xlrd==1.2.0
Yasser Mohsen
  • 1,411
  • 1
  • 12
  • 29

2 Answers2

29

Solved! I have replaced mysql-devel with mariadb-devel and it worked successfully, then I was able to install mysqlcient library.

My new 01_packages.config:

packages: 
  yum:
    python3-devel: []
    mariadb-devel: []

I don't know the root cause of it, but I did so as I noticed that the manual installation of mysql-devel through yum install mysql-devel is actually installing mariadb-devel !

Here is my ec2 instance release details. Maybe it is because of the new Amazon Linux Release 2.

$ cat /etc/*-release*
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
Amazon Linux release 2 (Karoo)
cpe:2.3:o:amazon:amazon_linux:2
Yasser Mohsen
  • 1,411
  • 1
  • 12
  • 29
  • 2
    I did some investigation, and indeed it seems that the old Amazon Linux AMI for Elastic Beanstalk included mysql, but the Amazon Linux 2 AMI for Elastic Beanstalk does not. So when upgrading from the old platform to the new one, it seems one has to add the correct packages to a config file, as Yasser said. I only needed mariadb-devel. – Oded Aug 05 '20 at 20:59
  • @Yasser Mohsen, That was it. – Faisal Nazik Mar 09 '22 at 05:09
3

Follow-up to this for 2023 for the new Linux Platforms:

mariadb-devel is no longer the name of the package. Instead, use

packages:  
  yum:  
    python3-devel: []
    mariadb105-devel.x86_64: []

For the future version, you can check for what packages you can install by:

  1. Connecting to you EC2 instance that has EB is using via Session Manager.
  2. Run yum list available
  3. Search for variations of the mariadb-devel (or even mysql-devel if they bring that back).
qulxis
  • 31
  • 1