(elasticbeanstalk, Django, postgresql) Unable to migrate existing data to elasticbeanstalk

Viewed 20

I have deployed my django api to the AWS elasticbeanstalk, after numerous trying, I successfully deployed the django app without any error => Environment update completed successfully. The log file also seems fine to me, I can access my django website. However, there is no data inside the elasticbeanstalk database. After looking into the log file. The django was successfully migrated. I have no idea what is going on here.

log file:

2022-09-08 16:20:37,014 P3694 [INFO] Command 01_makemigrations
2022-09-08 16:20:37,520 P3694 [INFO] -----------------------Command Output-----------------------
2022-09-08 16:20:37,521 P3694 [INFO]    No changes detected
2022-09-08 16:20:37,521 P3694 [INFO] ------------------------------------------------------------
2022-09-08 16:20:37,521 P3694 [INFO] Completed successfully.
2022-09-08 16:20:37,528 P3694 [INFO] ============================================================
2022-09-08 16:20:37,528 P3694 [INFO] Test for Command 02_migrate
2022-09-08 16:20:37,531 P3694 [INFO] Completed successfully.
2022-09-08 16:20:37,531 P3694 [INFO] ============================================================
2022-09-08 16:20:37,531 P3694 [INFO] Command 02_migrate
2022-09-08 16:20:38,080 P3694 [INFO] -----------------------Command Output-----------------------
2022-09-08 16:20:38,080 P3694 [INFO]    Operations to perform:
2022-09-08 16:20:38,081 P3694 [INFO]      Apply all migrations: admin, api, auth, contenttypes, sessions
2022-09-08 16:20:38,081 P3694 [INFO]    Running migrations:
2022-09-08 16:20:38,081 P3694 [INFO]      No migrations to apply.
2022-09-08 16:20:38,081 P3694 [INFO] ------------------------------------------------------------
2022-09-08 16:20:38,081 P3694 [INFO] Completed successfully.

env config:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: backend.wsgi:application
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: "backend.settings"

package config:

packages:
  yum:
    postgresql-devel: []

django config:

option_settings:
  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /static: static

container_commands:
  01_makemigrations:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py makemigrations"
    leader_only: true

  02_migrate:
    command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
    leader_only: true

I have also setup the database according to the documentation in the setting.py:

if 'RDS_DB_NAME' in os.environ:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': os.environ['RDS_DB_NAME'],
            'USER': os.environ['RDS_USERNAME'],
            'PASSWORD': os.environ['RDS_PASSWORD'],
            'HOST': os.environ['RDS_HOSTNAME'],
            'PORT': os.environ['RDS_PORT'],
        }
    }
else:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.postgresql_psycopg2",
            "NAME": "camping-product",
            "USER": "postgres",
            "PASSWORD": "postgres",
            "HOST": "localhost",
            'PORT': "5432",
        }
    }

After days of research and trying, I was not able to solve the issue, can anybody give me some hint on the issue? Much appreciated.

0 Answers
Related