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?

질문됨 일 년 전542회 조회
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
전문가
답변함 일 년 전
profile picture
전문가
검토됨 7달 전
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.

답변함 일 년 전
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

답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠