Insert the following ssh code
- Ask for the key (keep it somewhere safe)
- Add the following SSH info to your config
Host flask-app-ec2 HostName ec2-35-88-126-46.us-west-2.compute.amazonaws.com User ubuntu IdentityFile
- Make sure
app.run(debug=True)in app.py - Run
source venv/bin/activateto start your virtual environment - Run
python app.pyto start locally (optional)
- Run
pip freeze > requirements.txtin the virtual environment
Make sure you are in the virtual environment!!
- Restart and enable the flaskapp:
sudo systemctl restart flaskapp && sudo systemctl enable flaskapp - Check the localhost
curl -v http://localhost:8000 - Check the IP
curl http://35.88.126.46/?longitude=0&latitude=0... Always append http:// before any IP! - (optional) If you ever change the public IP, make sure to update it in the flaskapp configuration at /etc/nginx/sites-available/flaskapp
- (optional) reload the configurations and restart nginx. You can also modify gunicorn /etc/systemd/system/flaskapp.service
- Run the following cp lambda_function.py my-deployment-package/ cp -r venv/lib/python3.x/site-packages/* my-deployment-package/
- Push to GH
- Download zip from GH
- Deploy via AWS Lambda
Amazon RDS (Relational Database Service): To host your MySQL database. Amazon S3: To store static assets or backup data if needed. AWS IAM (Identity and Access Management): To manage access and permissions securely.