Reputation: 7275
Got a Flask app that has the Flask application
initialization in the main module's __init__.py
file, much like the Flask docs has here (except I'm not using an app factory type function)
myapp/
myapp/
__init__.py # application = Flask(__name__) is here
static/
templates/
...
requirements.txt
Local environment runs fine with flask run
when FLASK_APP
is set to myapp
.
My attempt with the Beanstalk deployment is via eb-cli
and I have the FLASK_APP
set in .ebextensions/options.yml
like so:
option_settings:
aws:elasticbeanstalk:application:environment:
LC_ALL: en_US.utf8
FLASK_APP: myapp
FLASK_ENV: production
Then I'm running:
eb init -p python-3.7 myapp --region us-east-1
eb create myapp-env
It seems to launch fine, but the environment becomes degraded, I get a 502 and the logs show that the Flask app does not launch correctly due to No module named 'application'
I was under the impression that setting FLASK_APP
would be enough to locate the Flask app instance.
How do I deploy a Flask app via Elastic Beanstalk in this context? Do I need to further specify the entry-point somehow?
Upvotes: 2
Views: 804
Reputation: 238051
Based on the comments.
The issue was caused by using custom flask application path. By default, EB expects the application to be located in application.py
file.
To solution was to specify the custom path using WSGIPath
in aws:elasticbeanstalk:container:python option:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: myapp:application
Upvotes: 2