3

I'm using elastic beanstalk and django. One of my dependencies in my requirements.txt file has some setup the it performs when it's initially imported. Part of the setup is to check whether a dir exists else it create it. I'm getting permissions errors because the user ( I assume it's wsgi) does not have the permissions to create the dir.

OSError: [Errno 13] Permission denied: '/home/wsgi/.newspaper_scraper/memoized'

How can I setup permissions to allow for these dirs to be created in a way that will be persistent across instances I create in the future?

Peter
  • 142
  • 1
  • 12
  • Can you paste your `requirements.txt`? – Daniel van Flymen Mar 28 '17 at 15:25
  • I might have worded the question a bit strangely by mentioning requirements. here is the settings file in the 3rd party package i mentioned. https://github.com/codelucas/newspaper/blob/master/newspaper/settings.py – Peter Mar 28 '17 at 15:29

1 Answers1

3

This is happening because the uWSGI worker is running under a user with limited permissions. You need to create the .newspaper_scraper/memoized directory first, and set the correct permissions on it (allow others to r/w). You can do this on deployment by making a script in .ebextensions that EB executes upon deployment.

Create a file in .ebextensions/setup_newspaper.config and add the following to it:

.ebextensions/setup_newspaper.config

packages:
  yum:
    libxslt-devel: []
    libxml2-devel: []
    libjpeg-devel: []
    zlib1g-devel: []
    libpng12-devel: []

container_commands:
  01_setup_newspaper:
    command: mkdir -p /home/wsgi/.newspaper_scraper/memoized && chmod 644 /home/wsgi/.newspaper_scraper/memoized


PS: It looks like newspaper requires some extra packages to be installed, so I added them too.


Read more info on .ebextensions here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html#create-deploy-python-custom-container

Daniel van Flymen
  • 10,931
  • 4
  • 24
  • 39