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
已提問 8 個月前檢視次數 378 次
3 個答案
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
專家
已回答 8 個月前
profile picture
專家
已審閱 1 個月前
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
已回答 8 個月前
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
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南