Question:
After successfully deploying a test app using the steps outlined here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_flask.html
I tried to deploy my actual flask application which has the following structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
myApp/ runServer.py requirements.txt myApp/ __init__.py helpers.py clean.sh static/ myApp.css handlers/ __init__.py views.py templates/ layout.html viewOne.html viewTwo.html |
Where views.py
contains my url mappings.
I have tried initializing the eb
instance in the root directory as well as within the myApp
module and git aws.push
but I get the following error on the AWS dashboard:
ERROR Your WSGIPath refers to a file that does not exist.
and the application does not work (404 for any path).
How can I deploy the above Flask
application to elastic beanstalk?
Answer:
Add the following to .ebextensions/<env-name>.config
:
1 2 3 4 |
option_settings: "aws:elasticbeanstalk:container:python": WSGIPath: myApp/handlers/views.py |
Update:
If you don’t have .ebextensions directory, please create one for the project. You can find more information of what can be done regarding the container configuration in Customizing and Configuring AWS Elastic Beanstalk Environments guide.