seed
Deploying Flask with Elastic Beanstalk
To get started, this AWS tutorial provides a gentle introduction. The guide herein aims to outline additional steps required of a real-world application, thereby condensing the most important components of Elastic Beanstalk's existing documentation.
Simple Workflow with CLI
Use the EB CLI to interact with Elastic Beanstalk applications and environments.
sh
# Initialize the EB application and the .elasticbeanstalk directory
eb init -p python-3.8 flask-tutorial --region us-east-2
# Set up SSH keys for your application
eb init
# Create the EB enviornment
eb create <name-of-application>
# Deploy updated code or configurations
eb deploy [name-of-application]
# SSH into the EC2 instance hosting the EB environment
eb ssh
# Initialize the EB application and the .elasticbeanstalk directory
eb init -p python-3.8 flask-tutorial --region us-east-2
# Set up SSH keys for your application
eb init
# Create the EB enviornment
eb create <name-of-application>
# Deploy updated code or configurations
eb deploy [name-of-application]
# SSH into the EC2 instance hosting the EB environment
eb ssh
Tips 'n Tricks
- When getting started, ensure that the base Flask app is named
application.py
, and that the top level Flask object is also namedapplication
, e.g.,application = Flask(__name__)
. - Including
.ebignore
has consequences with regards to which folders and files are uploaded to the EB deployment. See here and here. A better solution is to not use.ebignore
and instead rely on.gitignore
. EB will use if it'sMy current work around is to host the virtual environment in the /tmp directory, though finding a more sophisticated solution would be good.