{"id":15654386,"url":"https://github.com/briancaffey/terraform-aws-django","last_synced_at":"2025-04-30T22:50:13.232Z","repository":{"id":38027423,"uuid":"466938646","full_name":"briancaffey/terraform-aws-django","owner":"briancaffey","description":"Terraform modules for deploying Django applications on AWS using ECS Fargate","archived":false,"fork":false,"pushed_at":"2025-02-09T06:02:45.000Z","size":227,"stargazers_count":34,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-30T22:50:02.499Z","etag":null,"topics":["aws","django","ecs-fargate","terraform"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/briancaffey/django/aws/latest","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/briancaffey.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-07T04:13:20.000Z","updated_at":"2025-02-26T20:20:11.000Z","dependencies_parsed_at":"2025-03-09T17:42:42.963Z","dependency_job_id":null,"html_url":"https://github.com/briancaffey/terraform-aws-django","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancaffey%2Fterraform-aws-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancaffey%2Fterraform-aws-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancaffey%2Fterraform-aws-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancaffey%2Fterraform-aws-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briancaffey","download_url":"https://codeload.github.com/briancaffey/terraform-aws-django/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251795387,"owners_count":21645019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","django","ecs-fargate","terraform"],"created_at":"2024-10-03T12:51:24.752Z","updated_at":"2025-04-30T22:50:13.195Z","avatar_url":"https://github.com/briancaffey.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform AWS Django\n\n## About\n\nThis repo is a collection of Terraform modules for deploying Django applications on AWS. Currently the supported modules are:\n\n- ECS Fargate\n- EC2 using docker compose (WIP)\n\nThese two application architectures both use containers for running the core application, but have different levels of cost, security and complexity.\n\n### ECS Fargate\n\n- appropriate for production environments\n- expensive to run\n- https (Amazon Certificate Manager)\n- secure networking (3-tier VPC)\n- managed database (RDS)\n- managed cache (ElastiCache)\n- orchestration (ECS, AWS CLI, GitHub Actions)\n- pulls application images from ECR\n\n### EC2 Docker Compose\n\n- appropriate for non-critical production environments\n- inexpensive to run\n- https (certbot)\n- unsecure networking (runs in default VPC in a public subnet)\n- self-hosted database (docker volume, EBS)\n- self-hosted cache (docker volume, EBS)\n- orchestration (docker compose, Systems Manager, cloud-config, GitHub Actions)\n- builds application images from source code (docker compose build)\n\n## Directory structure\n\nThis IaC library has two main folders:\n\n- `modules`\n- `examples`\n\n### `modules` directory\n\nThe `modules` directory contains the Terraform modules. In the `modules` directory, the `internal` directory contains building blocks that are used by other \"high-level\" modules. The `internal` modules are organized by AWS service. For example, the `rds` module contains resources for building an RDS database, including a security group, a secret used for the database password, and the database instance.\n\n#### `ecs` module\n\nCurrent development efforts for this project are focused on improving the `ecs` module. This module is split into `base` and `app`.\n\nThe `base` module deploys long-lived resources that shouldn't need to be updated frequently, these include:\n\n- VPC\n- ElastiCache\n- S3\n- Security Groups\n- Load balancer\n- RDS\n\nThe `app` module deploys resources primarily for ECS services that run the application, these include:\n\n- ECS cluster for the environment\n- web-facing services (for running gunicorn and for running the frontend UI app)\n- celery worker for asynchronous task processing\n- celery beat for scheduled tasks\n- management_command for running migrations and other \"pre-update\" tasks (collectstatic, loading fixtures, etc.)\n- All backend environment variables are configured here (shared between all backend services)\n- Route 53 record for the environment (e.g. `\u003cenv_name\u003e.example.com`)\n- IAM resources (this might be able to be moved to the base stack)\n\nThe `base` and `app` modules could be split further into smaller modules for better separation of concerns. For example, you might want to split the base module into `networking`, `database`, etc. For simplicity, I just use the `base` and `app` modules.\n\nThe `app` module consumes the Terraform `outputs` from the `base` module, so you need to deploy the base module first.\n\nMultiple `app` environments can be deployed on top of a single `base` module.\n\nFor example, you may have a `base` environment called `production` with only one `app` environment called `app`. This would correspond to the production environment that would be made available at `app.example.com`.\n\nYou may choose to have another `base` environment called `dev` with multiple `app` environments used for different purposes, such as `qa`, feature-branch environments, or any other named environment (e.g. `alpha`, `beta`, etc.)\n\n### `examples` directory\n\nThe `examples` directory contains examples how each high-level application. These examples are used for quickly spinning up resources.\n\n## Companion application\n\nTo see how `terraform-aws-django` can be used, have a look at [https://github.com/briancaffey/django-step-by-step](https://github.com/briancaffey/django-step-by-step).\n\nThis companion repo includes two main components: a Django application (backend) and a Nuxt.js application (frontend)\n\n### Django backend application features\n\n- email-based authentication flow (confirmation email + forgot password)\n- microblog app (users can write posts with text and images, like posts)\n- chat app (a simple OpenAI API wrapper)\n\n### Nuxt.js frontend client features\n\n- Vue 3, Nuxt v3.15\n- SSR\n- shadcn\n- tailwindcss\n- pinia\n- composables\n\n## Usage\n\nThis module is not intended to work with any Django application, but it is a good starting point if your application structure and requirements are similar to those of the companion application.\n\n## Not documented\n\n- Creation of S3 bucket and DynamoDB table for Terraform backend\n- Creation of least-privilege IAM roles for use in GitHub Actions with OpenID Connect\n- Creation of ECR repositories\n\n## Roadmap\n\n- Finish module for EC2 with docker compose\n- Create reusable GitHub Actions that live in this repo and use them in the companion repo\n- Autoscaling for ECS application services\n- Support Kubernetes and EKS","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancaffey%2Fterraform-aws-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriancaffey%2Fterraform-aws-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancaffey%2Fterraform-aws-django/lists"}