Technical Guide: Automating deployment for Django, Celery, Redis, Postgres, and pgAdmin4 to AWS EC2 using Terraform and Docker

Joel Wembo
Django Unleashed
Published in
27 min readMar 18, 2024

--

DevOps automation is the addition of technology that performs tasks with reduced human assistance to processes that facilitate feedback loops between operations and development teams. In this technical handbook, we will study how we can automate the deployment of our existing Django web application to AWS EC2 server using Terraform and CloudFormation.

Photo by Timelab on Unsplash

Tables of Contents

· Tables of Contents
· Preface
· Abstract
· Introduction
· Prerequisites:
· Why Terraform?
· Can Django be used with AWS?
· Where to host a Django website?
· 1. Let's Start with Django
· 2. Dockerize the Django application
· 3. Create AWS Access Keys
· 4. AWS EC2 Provisioning Using Terraform and Github Actions
· 5. Create a Key Pairs
· 6. backend.tf
· 6.1 S3 bucket for terraform state management
· Replace remote backend with Terraform Cloud
· 6.2 Terraform Cloud Configuration
· 7. provider.tf
· 8. Define a file main.tf
· 9. Run Github Actions Pipeline
· 10. Check result in your AWS Management Console
· 11. Provision AWS RDS for PostgreSQL using terraform
· 12. Push the changes and Run Github Actions Pipeline
· 13. Setup CI/CD pipelines for our Django app to aws ec2 using GitHub actions
· 14. Check your application running live!
·…

--

--

Joel Wembo
Django Unleashed

I am a Cloud Solutions Architect @ prodxcloud. Expert in Django, AWS, AWS CDK, EKS, Serverless Computing & Terraform. https://www.linkedin.com/in/joelotepawembo