'AWS elastic beanstalk Linux 2 with Django application failed to deploy

I am in this strange situation where I could not deploy the same code base to elastic beanstalk Linux 2 server after first time. The first deployment(after intentionally crashed server or new environment) works with no error but if I deploy the same code base again, It would fail at python manage.py migrate command in my .config file.

command 01_migrateddb (source /var/app/venv/staging-LQM1lest/bin/activate && python manage.py migrate --noinput) failed

I tried to put all my eb container commands in .config into .platform/hooks as .sh scripts, the deployment works, but I would get 502 Bad Gateway error and unable to see my site.

Any insight?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source