All technological notes.
By default, Elastic Beanstalk looks for a file named application.py to start your application.
Configures Django project for Elastic Beanstalk:
requirements.txt$ pip freeze > requirements.txt
.ebextensions.$ mkdir .ebextensions
.ebextensions directory, add a configuration file named django.config with the following text:option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango.wsgi:application
aws:elasticbeanstalk:environment:proxy:staticfiles:
/static: static
WSGIPath, specifies the location of the WSGI script that Elastic Beanstalk uses to start application./static, specifies static dir~/proj_container/
|-- .ebextensions
| `-- django.config
|-- proj_dir
| |-- __init__.py
| |-- settings.py
| |-- urls.py
| `-- wsgi.py
|-- db.sqlite3
|-- manage.py
`-- requirements.txt
EB CLI repository with the eb init command.~/proj_container$ eb init -p python-3.7 <app_name>
SSH to connect to the EC2 instance running your application.~/proj_container$ eb init
Do you want to set up SSH for your instances?
(y/n): y
Select a keypair.
1) my-keypair
2) [ Create new KeyPair ]
~/proj_container$ eb create <env_name>
Elastic Beanstalk environment named env_name. Creating an environment takes about 5 minutes. As Elastic Beanstalk creates the resources needed to run your application, it outputs informational messages that the EB CLI relays to your terminal.eb status.~/ebdjango$ eb status
Environment details for: <env_name>
Application name: <app_name>
...
CNAME: eb-django-app-dev.elasticbeanstalk.com
...
CNAME property.settings.py file in the ebdjango directory. Locate the ALLOWED_HOSTS setting, and then add your application’s domain name that you found in the previous step to the setting’s value. If you can’t find this setting in the file, add it to a new line.ALLOWED_HOSTS = [
'eb-django-app-dev.elasticbeanstalk.com'
]
eb deploy. When run eb deploy, the EB CLI bundles up the contents of your project directory and deploys it to your environment.~/proj_container$ eb deploy
eb open.~/proj_container$ eb open
~/project_container$ eb terminate env-name
eb create again.