6

I'm having issue with hosting Flask App on AWS with Elastic Beanstalk. I followed document on AWS(which seems a little old?), and did some workaround suggested here. It works if I have this folder structure:

--application.py
 /static
 /templates
 requirements.txt
 .ebextensions
 .elasticbeanstalk

However, I want to make my application more structured. So I moved my folder structure to and it stopped working

--application.py
--.ebxtensions
--.elasticbeanstalk
  /app
     - __init__.py
     - /static
     - /templates

What I have tried is changing the settings in optionsettings.myapp-env, suggested here. But I got no luck.

(P.S. App works fine except not recognizing the static files folder)

Any help would be appreciated!

Community
  • 1
  • 1
xbb
  • 2,073
  • 1
  • 19
  • 34

2 Answers2

5

Looks like you need to change the path mapping to: "/static/": "app/static/"

This mapping maps the virtual (what you refer in your html) to the directory structure. Since you have changed the dirs, now you need to change the mapping too.

Alternatively you can do the same conf in the AWS Beanstalk web console as well. Need not do in the configuration files.

Sony Kadavan
  • 3,982
  • 2
  • 19
  • 26
  • I can't believe I haven't checked the configuration in Management Console, you saved my day! – xbb Mar 15 '14 at 17:24
  • 1
    Is this still a valid solution. I can't get it to work. I'm assuming that what I need to do is go to the AWS administration page for the environment, select the "Software Configuration" panel, and change the directory for the virtual path `/static/` from `static/` to `xyz/static/`, where `xyz` is the folder in my project containing my web app's package (corresponding to `app` in the OP). Is that right (because it doesn't work)? – orome Jan 11 '15 at 23:39
  • For the life of me I can't get this working. I'm running a Pyramid application on EB. Does anyone have advice? Here's a link to the question I made: https://stackoverflow.com/questions/47046273/static-files-for-pyramid-application-on-elastic-beanstalk – Drew Burnett Nov 01 '17 at 23:00
3

This seems to be the most recent incarnation of this question and I figured I'd chime in since this just killed me for hours trying to figure out what the heck was wrong because my configuration settings were fine and the error logs and request logs didn't show any problems. I finally opened the developer console and saw I was getting an ERR_BLOCKED_BY_CLIENT for all of my static assets. Ghostery apparently treats elastic beanstalk as a cross-domain analytics tracker, so yet another gotcha that probably needs to be documented somewhere. It's simple enough to turn that off on my end, but I'm only running a site for fun. I'm not sure what you would do if you try to deploy an actual product to elastic beanstalk and Ghostery blocks all of your static assets. Your clients are probably just going to think your site sucks and won't think to look. I guess you better bundle it all directly or use a CDN.

Adam Acosta
  • 603
  • 3
  • 6