
Deploy a Django starter project on AWS with Apache on Ubuntu EC2, connect to a Postgres RDS database, and implement CI/CD with CodeBuild and CodePipeline.
Prepare for an intermediate-level course by ensuring basic knowledge of Django, AWS, and HTML, CSS, and JavaScript, as fundamentals are not covered in depth and refresher slides are provided.
Explore the full course roadmap to deploy a django app with apache, ec2, and ci/cd, covering setup, aws basics, rds postgres, github workflows, and domain and ssl configuration.
Access course support through the Q&A forum where the instructor and peers help with questions, while you are encouraged to first solve problems on your own before posting.
Structure your sort process by taking it one step at a time, setting a schedule, and staying consistent without overdoing it to achieve slow, steady progress and long-term knowledge.
Install and run the final Django project on Windows by creating a virtual environment, installing requirements, and launching the local server in Visual Studio Code, with local settings notes.
Install python on windows with 3.12.x version, add python.exe to path, verify with python --version and pip --version; install Visual Studio Code and extensions like Plastic and Django support.
Install python on macOS from Python.org, verify Python and pip, then install and customize Visual Studio Code with Django support and useful extensions to prepare for Django development.
Learn how to set up a Django project on Windows: create a dev folder, create and activate a virtual environment, install Django, start the project, and run the development server.
Set up a django project on macOS by configuring full disk access, creating a virtual environment, installing django, and running the development server at localhost.
Set up a Django project by running default migrations, creating a new app (CRM), adding it to installed apps, and starting the server to verify setup.
Configure an app-level base template, define a urls.py and a simple home view to render index.html, wire the CRM URLs into the project, and run the server to test.
Create a Django model named Daily Note with a title field (char field, max length 100), run migrations to the sqlite database, and register it in the admin.
Create a super user, start the Django development server, and access the Django admin at /admin to manage the CRM app's daily note model.
Build a basic Django form for notes by creating forms.py, importing the daily note model, and using a model form for the title field; then connect it to a view.
Create a Django view that imports the daily note model and form, handles post requests, validates and saves notes, then redirects home and displays all notes on the index page.
Create a static folder in the project base and configure Django to serve css and JavaScript static files from base/static.
Set up css and javascript in a Django app by creating static/css and static/js folders, linking styles.css and app.js, and testing with a hard reload.
Style the Django form with basic css in styles.css, targeting the note-form id, adding borders, padding, radius, and a blue hover button to test static files in production for ci/cd.
Create a free AWS account by visiting aws.amazon.com, entering your email and account name, verifying your email, and following the setup wizard.
Navigate the AWS management console to set regions, search and access services like EC2, S3, RDS, and IAM, and bookmark favorites for quick access.
Learn how to create AWS budgets, set email alarms near or above your threshold, and forecast future costs to monitor and control spend on your Django deployment.
Create and configure a designated budget using AWS budgets, set monthly cost limits, enable 80% alerts, and receive email notifications to manage AWS costs.
Explore AWS identity and access management (IAM) by creating users and groups, attaching JSON policies, and using inherited permissions while safeguarding access keys.
Learn to create an IAM user and the developers group, attach administrator access and password change policies, add the user to the group, and access the AWS management console.
Learn to sign in to the AWS management console as an IAM user using a unique URL, replace the account ID with an account alias, and enable MFA.
Learn to secure AWS accounts by enabling multi-factor authentication for both IAM users and the root account using an authenticator app, scanning a QR code, and entering consecutive MFA codes.
Explore Amazon RDS, a managed relational database service that lets you create relational databases in AWS, with engines like Postgres, MySQL, and Oracle.
Provision a Postgres database on Amazon RDS by updating your Django settings with a Postgres engine, installing psycopg2, and configuring RDS credentials, endpoint, and port 5432.
Provision a PostgreSQL database with Amazon RDS and connect it to your Django app by configuring the endpoint in settings.py and updating the security group for Postgres port 5432.
Create a superuser and populate the production Postgres database with sample notes to test the live environment; verify data via the Django admin page.
Create a GitHub account by signing up, verifying your email, and signing in, then upload your course code to a secure GitHub repository to prepare for the next lesson.
Install and set up Git on your machine, choose the 64-bit Windows setup and ensure the Git credential manager is selected, then launch Git Bash to push code to GitHub.
Generate a requirements.txt file by running pip freeze inside your virtual environment to capture all packages used in your Django project, preparing for deployment to Apache on Amazon EC2.
Configure environment variables to keep secrets like the Django secret key and database credentials safe by using os.environ.get in settings.py and Apache, with future AWS secret manager steps.
Secure your application's sensitive data by configuring environment variables safely on your Apache server, then store secrets in AWS Secrets Manager for enhanced protection.
Configure Django static handling for production by defining a static route in the base directory, collecting static files, and organizing custom and Django admin assets.
Prepare deployment by creating requirements.txt with django and psycopg2 binary, configuring environment variables for secret key and database, collecting static files, setting debug to false, and temporarily allowing all hosts.
Generate a GitHub personal access token with full repository access and repo hooks to enable pushing code and AWS CodeBuild and CodePipeline integration.
Learn to create a private GitHub repository, initialize a Django project, and push code to main via git commands and a remote origin with a personal access token.
Explore Amazon EC2, the on-demand virtual server at the core of IaaS, and learn to scale with auto scaling groups, load balancers, and storage options like EBS and EFS.
Launch your first EC2 instance by selecting the Ubuntu AMI, choosing a 64-bit t2 micro under the free tier, and configuring a key pair and security group.
Generate an ssh key on the EC2 instance, add the key to GitHub, and verify SSH access to private repositories so you can clone them to EC2.
Update the EC2 system and install Python 3.12, pip, and Python virtual environment. Use Git to clone the repository via SSH, activate the virtual environment, and install dependencies from requirements.txt.
Install and configure Apache and mod_wsgi to serve a Django app, enable the wsgi module, and set up the default virtual host for static files and the wsgi entry point.
Configure an Apache virtual host for a Django app on EC2 using a base template, set server name, document root, wsgi, environment variables, and static files.
Test that apache is running by checking the status with sudo systemctl status apache2, verify syntax with apache2ctl configtest, set permissions with chmod 755, and restart apache2 to apply changes.
Configure allowed hosts in Django settings and load environment variables from Apache into wsgi.py, then push changes to GitHub and pull updates on EC2 to enable dynamic loading.
Test and fix form styling issues in a Django app deployed to Apache, addressing a mod_wsgi rendering bug with Python 3.12 by removing dot underscore p and adding explicit labels.
Learn to fix Django admin login form styling by conditionally displaying username and password errors, edit login.html, and test login flows on an EC2 deployment.
Master manual redeployment of a Django app by updating code, pushing to GitHub, pulling on EC2, and restarting Apache, foreshadowing automated CI/CD with AWS.
Prepare for the next section as you automate deployment with CI/CD on Amazon EC2. Learn about DevOps, AWS CodeBuild and CodeDeploy, Secrets Manager, CodePipeline, and cache busting for static files.
Define DevOps as the intersection of development and operations, highlighting how collaboration between teams and automation improves efficiency and consistency in the software delivery life cycle.
Learn how CI and CD automate building, testing, and deploying code to deliver updates faster and reliably. Use git with GitHub, AWS CodeBuild, CodePipeline, CodeDeploy, Django, and Apache on EC2.
Explore the aws ci/cd pipeline architecture for deploying a django app on ec2. Push code via GitHub, codebuild tests, and codedeploy/codepipeline, with rds, route 53, certbot, and secrets manager.
Explore AWS CodeBuild, a service that compiles source code, runs tests, and produces packages. See how built artifacts are packaged and sent to CodeDeploy for deployment.
Create and configure an AWS CodeBuild project linked to a GitHub repository to enable a full CI/CD pipeline with CodeDeploy and CodePipeline, using a buildspec.yml and webhook.
Discover AWS CodeDeploy, an AWS service that enables quick deployment and redeployment with zero downtime via blue-green deployment, keeping your application online during updates.
Explore CodeDeploy setup, including creating a CodeDeploy role, application, and deployment group, attaching an EC2 IAM role, and installing the CodeDeploy agent to automate deployments with AppSpec.
Set up a CodeDeploy role to connect AWS CodeDeploy with EC2, then create an application and a deployment group to manage EC2 deployments.
Create and attach an IAM role for EC2 to enable Code Deploy interactions, granting the EC2 instance the permissions needed to receive and apply deployment updates.
Install and set up the CodeDeploy agent on a single EC2 instance, including dependencies, downloading the installer, and starting and validating the CodeDeploy agent.
Protect your application access by using AWS Secrets Manager to securely store secrets and encrypt them with KMS, while integrating with multiple AWS services.
Learn to protect sensitive data with AWS Secrets Manager by storing Django environment variables as key-value pairs, avoiding plain text, and understanding the $0.40 per secret monthly cost.
Grant IAM role permissions to allow the EC2 instance to read and write secrets from AWS Secrets Manager, enabling dynamic loading of environment variables into Apache configuration.
install the aws cli on an ec2 instance using curl, unzip, and the installer, then verify the version to enable access to aws secrets manager and environment variables.
Configure Apache to dynamically load environment variables from AWS Secrets Manager using the AWS CLI, editing /etc/apache2/envvars, and exporting secret key, user, password, and host.
Replace hard-coded environment values, including secret_key, user, password, and host, with dynamic placeholders in the env vars file and Apache config, then restart Apache and verify Django loads.
Understand how AWS CodePipeline orchestrates the CI/CD process from CodeCommit to CodeDeploy, coordinating CodeBuild for build and test and delivering deployment to your application.
Set up build, deploy and start scripts for automation using buildspec.yml and appspec.yml, integrating with AWS CodeBuild and CodeDeploy, and handling migrations, static files, and Apache restart.
Grant AWS CodeBuild Secrets Manager read access by attaching a read/write policy to its service role, enabling buildspec.yml to retrieve the secret and export environment variables.
Push scripts to GitHub and test the buildspec with CodeBuild, reviewing build history, logs, and package installation from requirements.txt to ensure migrations, static files, and a successful build.
Integrate source, build, and deploy stages with CodePipeline to orchestrate automated deployments from GitHub through CodeBuild to CodeDeploy.
Invoke the CodePipeline process by pushing code to GitHub, watch the pipeline auto-detect changes, build, and deploy your web application, and understand the CI/CD workflow.
Enable automatic cache busting by configuring Django's manifest static files storage in settings.py to rename assets with a hash, ensuring the latest versions load after deployment.
Explore AWS Route 53, a DNS service for domain registration and DNS records, mapping domains to AWS resources with A, CNAME, and alias records, plus routing policies.
Register a domain with AWS Route 53 by searching for availability, selecting a domain, and completing checkout phases—pricing, contact information, and review—then monitor status in requests and hosted zones.
Learn how certbot automates obtaining and renewing free ssl certificates from Letsencrypt to enable https on your apache or nginx server, ensuring domain-ready sites stay secure against man-in-the-middle attacks.
Map your server IP address to a domain name by creating A records in Route 53, linking your EC2 public IPv4 to eden.com and www.
Configure the EC2 security group to allow HTTPS by adding inbound rules for port 443 for both IPv4 and IPv6, then save changes.
Install and configure a free SSL certificate with Certbot on Apache in EC2, enable HTTPS, bind domain names, update Django allowed hosts, and verify via the CI/CD pipeline.
Learn to clean up AWS resources to avoid costs by deleting a database (RDS), EC2 instance, code pipeline, code build, code deploy, secrets manager secret, and Route 53 A records.
Welcome! I'm here to guide you in deploying your Django web applications with Apache on Amazon EC2 and automating your deployment process using CI/CD pipelines.
-- Please read carefully --
In this course we will learn a variety of new concepts, manners of deploying a lot of extra technologies along the way.
_________________________
What you'll learn (In-depth):
_________________________
Django setup & development:
Learn the essentials of building and configuring a Django application for deployment.
Set up your development environment for a seamless workflow, focusing on local development environments and ensuring smooth transitions to production.
Master Django configuration for production, including setting allowed hosts, static files, and environment variables.
Amazon EC2 deployment:
Deploy a Django app on an EC2 instance with Apache and mod_wsgi, focusing on the basics of server management.
Configure the EC2 instance using Linux-based commands, including managing updates, installing dependencies, and ensuring smooth operation.
Secure your EC2 instance, including setting up SSH keys, managing server security groups, and configuring Apache virtual hosts for a reliable production environment.
Troubleshoot and test your Apache configuration to ensure it serves your Django app correctly.
Linux-Based Commands on EC2 (Ubuntu):
Use common Linux commands to manage your EC2 instance (Ubuntu AMI), such as updating the system, installing dependencies, managing files, and monitoring resources.
Learn to navigate the terminal for remote access and file management, including SSH into the EC2 instance and basic system administration tasks.
Get comfortable using the command line to handle server tasks like starting/stopping services, viewing logs, and debugging errors in production.
CI/CD automation:
Implement CI/CD pipelines using AWS CodePipeline, CodeBuild, and CodeDeploy to automate your deployment process.
Set up and configure each stage of the pipeline to integrate with your GitHub repository, build code, and deploy it automatically to your EC2 instance.
Learn the AWS CLI commands and use them to test and manage your CI/CD pipeline directly from the terminal.
Ensure fast, reliable, and secure updates to your Django app, reducing manual intervention.
Cloud Infrastructure:
Work with core AWS services such as EC2 (Elastic Compute Cloud), RDS (Relational Database Service), and IAM (Identity and Access Management) to build and manage a secure, scalable cloud infrastructure for your Django application.
Set up a PostgreSQL production database with Amazon RDS and ensure your Django app connects to it securely.
Understand IAM roles, security groups, and how to secure sensitive data and access within your AWS environment.
Secure environment variables with AWS Secrets Manager:
Learn to use AWS Secrets Manager to store and retrieve sensitive data such as database credentials, API keys, and other environment variables securely.
Programmatically integrate AWS Secrets Manager with your Django application to dynamically load environment variables, reducing the risk of exposing sensitive information in the codebase.
Configure IAM roles and policies to control access to secrets, ensuring that only the necessary services and users can retrieve them.
Register a domain name with Amazon Route53 and setup SSL certification with Certbot:
Register a domain name with Amazon Route53 and then use Certbot to obtain and install SSL certificates for your domain name, securing the connection to your Django app with HTTPS.
Integrate the SSL certificate with Apache to enforce secure communications and protect user data.
Simplified IaaS Approach:
Focus on an Infrastructure as a Service (IaaS) model where you're working with a single EC2 instance, without the complexity of load balancing or auto-scaling.
Learn how to configure and deploy Django on a simple, single EC2 instance, focusing on scalability at the application level and managing the server environment efficiently.
Get hands-on experience working with a minimal, cost-effective setup that is easy to manage and scale manually as your application grows.
This course is designed to give you a comprehensive understanding of deploying Django apps on AWS using EC2 with a hands-on, practical approach. You’ll build the foundational skills to manage servers, automate deployments, secure your application, and work with cloud infrastructure, all within a simplified and focused environment.
I want to help YOU master the fundamentals of deploying your Django web apps to Apache on Amazon EC2 with CI/CD!
The Deploy a Django web app with Apache, Amazon EC2 and CI/CD course has been structured in a simple and logical order. Everything that has been designed from the styling to the graphics and topics covered is crafted with the absolute duty of care towards the student.
The Deploy a Django web app with Apache, Amazon EC2 and CI/CD course is a highly practical course and allows you to apply your knowledge:
There is a wealth of hands-on lectures throughout this course.
Your instructor:
My name is Arno Pretorius. I'm a qualified IT teacher who has taught programming both in-person and online. My main passions are teaching and technology, so I thought why not just combine the best of both worlds to create something truly amazing and valuable. Over the years, I have created and deployed many real-world Django-based applications, including a job portal for university graduates and an exclusive social network.
I'm a Software developer, an AWS Solutions Architect and Developer associate. I have a keen interest in cloud computing, web development and everything that relates to programming and technology.
Trust me you are in good hands!
This course also comes with:
- 8+ hours of on-demand video
- Full lifetime access
- A Udemy certificate of completion
- Downloadable resources
- Articles
- Access on mobile and TV
Join me in this course if you want to master the fundamentals of deploying your Django web app with Apache, Amazon EC2 and CI/CD!