{"id":20828441,"url":"https://github.com/codewithmuh/django-ecs-terraform-master","last_synced_at":"2026-02-16T14:03:53.519Z","repository":{"id":210526649,"uuid":"625190334","full_name":"codewithmuh/django-ecs-terraform-master","owner":"codewithmuh","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-03T11:40:55.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-15T09:02:20.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewithmuh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-08T10:43:36.000Z","updated_at":"2024-02-29T03:07:59.000Z","dependencies_parsed_at":"2023-12-03T12:49:55.230Z","dependency_job_id":null,"html_url":"https://github.com/codewithmuh/django-ecs-terraform-master","commit_stats":null,"previous_names":["rashiddaha/django-ecs-terraform-master","codewithmuh/django-ecs-terraform-master"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codewithmuh/django-ecs-terraform-master","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fdjango-ecs-terraform-master","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fdjango-ecs-terraform-master/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fdjango-ecs-terraform-master/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fdjango-ecs-terraform-master/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewithmuh","download_url":"https://codeload.github.com/codewithmuh/django-ecs-terraform-master/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmuh%2Fdjango-ecs-terraform-master/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275232726,"owners_count":25428227,"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","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-17T23:14:53.411Z","updated_at":"2026-02-16T14:03:48.481Z","avatar_url":"https://github.com/codewithmuh.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploying Django to AWS ECS with Terraform\n\nSets up the following AWS infrastructure:\n\n- Networking:\n    - VPC\n    - Public and private subnets\n    - Routing tables\n    - Internet Gateway\n    - Key Pairs\n- Security Groups\n- Load Balancers, Listeners, and Target Groups\n- IAM Roles and Policies\n- ECS:\n    - Task Definition (with multiple containers)\n    - Cluster\n    - Service\n- Auto scaling config\n- RDS\n- Health Checks and Logs\n\n\n\n## Want to use this project?\n\n1. Install Terraform\n\n1. Sign up for an AWS account\n\n1. Create two ECR repositories, `django-app` and `nginx`.\n\n1. Fork/Clone\n\n1. Build the Django and Nginx Docker images and push them up to ECR:\n\n    ```sh\n    $ cd app\n    $ docker build -t \u003cAWS_ACCOUNT_ID\u003e.dkr.ecr.us-west-1.amazonaws.com/django-app:latest .\n    $ docker push \u003cAWS_ACCOUNT_ID\u003e.dkr.ecr.us-west-1.amazonaws.com/django-app:latest\n    $ cd ..\n\n    $ cd nginx\n    $ docker build -t \u003cAWS_ACCOUNT_ID\u003e.dkr.ecr.us-west-1.amazonaws.com/nginx:latest .\n    $ docker push \u003cAWS_ACCOUNT_ID\u003e.dkr.ecr.us-west-1.amazonaws.com/nginx:latest\n    $ cd ..\n    ```\n\n1. Update the variables in *terraform/variables.tf*.\n\n1. Set the following environment variables, init Terraform, create the infrastructure:\n\n    ```sh\n    $ cd terraform\n    $ export AWS_ACCESS_KEY_ID=\"YOUR_AWS_ACCESS_KEY_ID\"\n    $ export AWS_SECRET_ACCESS_KEY=\"YOUR_AWS_SECRET_ACCESS_KEY\"\n\n    $ terraform init\n    $ terraform apply\n    $ cd ..\n    ```\n\n1. Terraform will output an ALB domain. Create a CNAME record for this domain\n   for the value in the `allowed_hosts` variable.\n\n1. To apply the migrations, run the following command, making sure to replace `YOUR_SUBNET_1`, `YOUR_SUBNET_2`, and `YOUR_SECURITY_GROUP` with the values that were outputted to your terminal from the `terraform apply` command:\n\n    ```sh\n    $ aws ecs run-task \\\n        --cluster production-cluster \\\n        --task-definition django-migration-task \\\n        --launch-type FARGATE \\\n        --network-configuration \"awsvpcConfiguration={subnets=[YOUR_SUBNET_1, YOUR_SUBNET_2],securityGroups=[YOUR_SECURITY_GROUP],assignPublicIp=ENABLED}\"\n    ```\n\n1. Now you can open `https://your.domain.com/admin`. Note that `http://` won't work.\n\n1. To collect the static files, navigate to the \"deploy\" folder, create and activate a Python virtual environment, install the requirements, and then run the following command, making sure to replace `\u003cAWS_ACCOUNT_ID\u003e` with your AWS account ID:\n\n    ```sh\n    (env)$ python update-ecs.py \\\n            --cluster=production-cluster \\\n            --service=production-service \\\n            --image=\"\u003cAWS_ACCOUNT_ID\u003e.dkr.ecr.us-west-1.amazonaws.com/django-app:latest\" \\\n            --container-name django-app\n    ```\n\n    You can use the same command to bump the Task Definition and update the Service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmuh%2Fdjango-ecs-terraform-master","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewithmuh%2Fdjango-ecs-terraform-master","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmuh%2Fdjango-ecs-terraform-master/lists"}