Don't already have an account? Create an account.
By creating an Ordinary Coders account, you agree to Ordinary Coders' Terms and Conditions.
If you already have an account, login instead.
Create an account and receive your first 100 points. Submit an article to earn more and unlock your first project.
Amazon Web Services offers an online integrated development server (IDE) so you can develop, debug, and run your code with just a browser.
This service is called AWS Cloud9 and like almost everything else on AWS, you only pay for what you need.
Compute and Storage fees are the only charges and will run you about $2.00 USD if you use Cloud9 for around 4 hours a day for 20 days.
This article is a complete walkthrough of how to set up the default AWS Cloud9 settings to develop a Django, a Python-based web framework, project.
How to create an AWS account
To begin, you will need to create an AWS account. The process is straightforward and you will only be charged for the services you use on AWS.
Locating the Cloud9 service
Once signed up, click on the search bar and search for the "Cloud9" service.
Or scroll down to the Developer Tools section under All Services and click "Cloud9".
Click on "Cloud9" to go to the Cloud9 homepage.
Creating a new Cloud9 environment
AWS Cloud9 Homepage
Once on the Cloud9 homepage, click on the orange button "Create environment".
Step 1: Name environment
You are prompted to enter the name of your environment.
We recommend you name the environment something comprehensive so you can remember what's in it.
You can also choose to add a description if you so choose.
Step 2: Configuration settings
Next are the environment configuration settings.
For Environment type, leave "Create a new EC2 instance for the environment (direct access)" selected.
For Instance type, leave it at "t2.micro (1 GiB RAM +1 vCPU)". This is the most cost-effective instance if you are just getting started.
For Platform, change the setting to "Ubuntu Server 18.04 LTS". However, feel free to use Linux if you are more familiar with that operating system.
Finally, for Cost-saving settings, leave the amount at the default "After 30 minutes". This means auto-hibernate will apply after 30 minutes of inactivity to prevent you from being unnecessarily charged for leaving the server running.
Step 3: Review
Review the environment name and configurations, then click the button "Create environment" when you are ready.
Getting started with AWS Cloud9
AWS Cloud9 Creating a new environment
It will take a few minutes for the environment to finish the setup.
From there you will see two tabs a "Welcome" tab and an "AWS Toolkit - Quick Start".
Both provide helpful information on customizing AWS Cloud9.
Feel free to read these documents as we will just be reviewing the basics needed to get a Django project up and running.
AWS Cloud9 IDE
What is included in AWS Cloud 9?
How to create a virtual environment in Cloud9
AWS Cloud9 Terminal
user:~/environment $ python3 -m venv env
user:~/environment $ cd env
user:~/environment/env $ source bin/activate
(env) user:~/environment/env $
To create a virtual environment in Cloud9 named env:
Create a virtual environment.
python3 -m venv env
Enter into the virtual environment folder.
And activate the virtual environment.
If you would like to know more about virtual environments visit, Creating a Python Virtual Environment for Beginners.
Install Django web framework
(env) user:~/environment/env $ pip install django==2.1.15
You must install a version of Django 2 if you are planning on deploying with AWS Elastic Beanstalk.
We will be using AWS EB for this tutorial.
Create a Django project and web app
(env) user:~/environment/env $ django-admin startproject mysite
(env) user:~/environment/env $ cd mysite
(env) user:~/environment/env/mysite $ python3 manage.py startapp main
With Django installed, we can move on to creating the actual Django project and the app within it.
To create a project named mysite:
django-admin startproject mysite
To create the app:
python3 manage.py startapp main
For more explanation on Django installation and initial setup, visit Django Quick Start Installation.
How to run the Cloud9 Server
AWS Cloud9 Code Editor
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 2.1.15.
For more information on this file, see
For the full list of settings and their values, see
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = 
# Application definition
INSTALLED_APPS = [
Before running the server, we need to update the Django settings.py file with the allowed host.
Go to the file tree on the left side of the IDE and double click env > mysite > mysite > settings.py.
The Django settings.py file will open in the Cloud9 code editor. It will look like the file above.
ALLOWED_HOSTS = ['*']
Scroll down to the ALLOWED_HOSTS and list an asterisk within the brackets, allowing all hosts. Save the file.
Alternatively, you can leave the ALLOWED_HOSTS blank, run the server, then grab the domain URL after.
(env) user:~/environment/env/mysite $ python3 manage.py runserver 8080
To run the Cloud9 server, you need to run the command python3 manage.py runserver 8080. This will create a Cloud9 URL for your development server.
python3 manage.py runserver 8080
Upon running the command, a green box will appear with the link to where your code is running.
Click the link.
Django Rocket in a browser window
You should see the Django rocket.
Django error when trying to run the Cloud9 server
If you are getting the Django yellow page error
Invalid HTTP_HOST header: 'abcd.vfs.cloud9.us-west-2.amazonaws.com'. You need to add 'abcd.vfs.cloud9.us-west-2.amazonaws.com' to ALLOWED_HOSTS.
ALLOWED_HOSTS = ['abcd.vfs.cloud9.us-west-2.amazonaws.com']
Go back to the Django settings.py file and add the URL given in the Django error under ALLOWED_HOSTS. Save the file, reload the browser.
Deploying Django from Cloud9 to AWS EB
AWS Elastic Beanstalk Django deployment
Once you have finished development, you can deploy your Django project on your cCloud9 environment to an AWS Elastic Beanstalk environment.
If you are looking to deploy your web app using the AWS Elastic Beanstalk Command Line Interface, follow the instructions provided in the course Building A Django Web App for more information.
Or if you can choose to deploy directly from the AWS Elastic Beanstalk Console with your zipped project.
Django Stripe SaaS Boilerplate
Django and Stripe integrated together to create a SaaS boilerplate. Django authentication, static files, messages, forms, templates, URLs, …
Django Powered Blog for Affiliate Marketing
A Django powered blog and product showcase for affiliate marketing from Building a Django Web App course. Pre-built Django …
Follow us @ordinarycoders
Post a Comment
Join the community
April 25, 2020, 2:43 p.m.
July 14, 2021, 11:32 a.m.
July 5, 2021, 2:47 p.m.
June 14, 2021, 5:20 p.m.
April 14, 2021, 10:03 a.m.
March 29, 2021, 7:30 p.m.