Search code examples
djangoamazon-web-servicesdeploymentzipamazon-elastic-beanstalk

Has anyone been able to deploy a Django project to elasticbeanstalk by uploading a zip file?


I have been able to deploy django projects using: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html , which is deployment from terminal on my mac. But I haven’t been able to do it by uploading a zip file. “ebdjango” is the name of my project. django.config contains:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: ebdjango.wsgi:application

requirements.txt contains:

asgiref==3.7.2
Django==4.2.9
sqlparse==0.4.4
typing_extensions==4.9.0

I am not sure if there is something wrong with how I create the zip file because i get the warning message: “Configuration files cannot be extracted from the application version ebdjango. Check that the application version is a valid zip or war file.” What I do is I compress .ebextensions, ebdjango manage.py and requirements.txt . When I open the zip file there is a root folder with the same name as the zip file and that folder contains .ebextensions, ebdjango manage.py and requirements.txt . Is it supposed to be like that or is everything supposed to be extracted from the zip when i open it without a parent folder? Is this why I can’t deploy my django project to elasticbeanstalk?


Solution

  • Use the zip command to create a source package. To include hidden files and folders, use the pattern shown below.

    ~/myapp$ zip ../myapp.zip -r * .[^.]*
      adding: app.js (deflated 63%)
      adding: index.js (deflated 44%)
      adding: manual.js (deflated 64%)
      adding: package.json (deflated 40%)
      adding: restify.js (deflated 85%)
      adding: .ebextensions/ (stored 0%)
      adding: .ebextensions/xray.config (stored 0%)