AWS Elastic Beanstalk: Installing MySQL Python package for Django app

1

I am trying to deploy a Django app.

My code works on my localhost (Mac computer) without any error as I have manually installed the MySQL Python package in my virtual environment. I cannot deploy my project on AWS Elastic Beanstalk because there is no MySQL Python package on AWS Elastic Beanstalk. I am using EB CLI commands to deploy my Django app to the AWS Elastic Beanstalk instance.

From RDS, I have created a MySQL database outside my environment so that my database exists in case I delete the environment.

Whenever I try to deploy my Django app it does not work. I see the following error when I visit my website URL: 502 Bad Gateway nginx

In the .extensions folder, I have created a file named as 01_packages.config and added the following lines: packages:
yum:
mariadb105-devel.x86_64: []

It did not help too.

What is the correct way to install MySQL Python package on AWS Elastic Beanstalk when we use EB CLI commands to deploy a Django app?

What should I do so that MySQL Python package automatically gets installed in my AWS Elastic Beanstalk instance?

Tanzil
asked 8 months ago362 views
3 Answers
0

Hello.

Is it possible to deploy as per the following documentation and still use it?
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

profile picture
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 23 days ago
0

@ Riku_Kobayashi

The link works until I use the MySQL.

I can deploy without any problem when I use the following settings:

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": BASE_DIR / "db.sqlite3",
    }
}

BUT when I try to use the following settings and try to deploy using EB CLI, I get a "502 Bad Gateway nginx" error. Interestingly, the following settings work on my localhost without any problem.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<actual_database_name>',
        'USER': '<actual_user_name>',
        'PASSWORD': '<actual_database_password>',
        'HOST': 'mysql-rdbms.blah-blah.us-west-2.rds.amazonaws.com',
        'PORT': '3306',
    }
}

As soon as I try to use the MySQL part, I cannot deploy.

Also please note that there is no mention of MySQL in the following document: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html

So, my problem is - there is no MySQL Package on AWS Elastic Beanstalk EC instance and I do not find a way to install it on AWS Elastic Beanstalk EC instance.

Tanzil
answered 8 months ago
0

You could try the follow yum package settings, the package names seem to be changed every now and again.

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

I am also stuck on the same issue, but just noticed the difference in your .config file

wmbm
answered 25 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions