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?
WSGIPathas your application is notapplication.py. You can use aws:elasticbeanstalk:container:python in order to do so.WSGIPath: application.application.pyinstead of__init_.py, to confirm that this is actually the issue.application.pyshould be in root of your folder, not subfolders. Also.ebextensions/options.ymlis incorrect. The extension should be.config. If you confirm this, then you know where to concentrate the efforts to solve the issue. Not sure how to use__init__.py. Would have to try-and-see how to use it inWSGIPath.WSGIPath: myapp:application. You want to put this as an answer? I'll mark it correct.