{"id":34841326,"url":"https://github.com/tukue/terraform-ecs-app","last_synced_at":"2026-04-19T21:08:34.277Z","repository":{"id":296849930,"uuid":"990653732","full_name":"tukue/terraform-ecs-app","owner":"tukue","description":"This repository contains the code for deploying a containerized task management application on AWS ECS using Terraform. It includes infrastructure modules for networking, security, ECS cluster setup, and ECR integration. The application is built with FastAPI and provides a simple interface for managing daily tasks.","archived":false,"fork":false,"pushed_at":"2025-06-02T17:27:47.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-02T23:54:42.095Z","etag":null,"topics":["aws-ecs","ecr","fastapi","terraform"],"latest_commit_sha":null,"homepage":"","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/tukue.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2025-05-26T12:38:05.000Z","updated_at":"2025-06-02T19:09:26.000Z","dependencies_parsed_at":"2025-06-03T00:07:59.646Z","dependency_job_id":null,"html_url":"https://github.com/tukue/terraform-ecs-app","commit_stats":null,"previous_names":["tukue/terraform-ecs-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tukue/terraform-ecs-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tukue%2Fterraform-ecs-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tukue%2Fterraform-ecs-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tukue%2Fterraform-ecs-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tukue%2Fterraform-ecs-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tukue","download_url":"https://codeload.github.com/tukue/terraform-ecs-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tukue%2Fterraform-ecs-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32022620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":["aws-ecs","ecr","fastapi","terraform"],"created_at":"2025-12-25T17:02:11.097Z","updated_at":"2026-04-19T21:08:34.272Z","avatar_url":"https://github.com/tukue.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ECS-Based Application Infrastructure\n\nThis project contains the infrastructure code for deploying a containerized application on AWS ECS using Terraform.\n\n## Project Structure\n\nThe infrastructure is organized into modules:\n\n- **Network Module**: VPC, subnets, internet gateway, NAT gateway, and route tables\n- **Security Module**: Security groups and IAM roles\n- **ECS Module**: ECS cluster, task definition, service, and ECR repository\n\n## Deploying the Infrastructure\n\nFollow these steps to deploy the infrastructure:\n\n1. Initialize Terraform:\n   ```bash\n   terraform init\n   ```\n\n2. Review the execution plan:\n   ```bash\n   terraform plan\n   ```\n\n3. Apply the changes to create the infrastructure:\n   ```bash\n   terraform apply\n   ```\n\n4. When prompted, type `yes` to confirm the deployment.\n\n5. After deployment, you can view the outputs:\n   ```bash\n   terraform output\n   ```\n\n6. To destroy the infrastructure when no longer needed:\n   ```bash\n   terraform destroy\n   ```\n\n## Remote State Management\n\nThis project separates remote state management from the main Terraform configuration. This allows you to:\n1. Start with local state for development\n2. Optionally use remote state for team collaboration\n\n### Using Local State (Default)\n\nBy default, the project uses local state. To ensure you're using local state:\n\n```bash\n# Make the script executable\nchmod +x use-local-state.sh\n\n# Run the script\n./use-local-state.sh\n```\n\n### How to Use Remote State\n\nThis project provides scripts to easily switch between local and remote state:\n\n#### Using Local State (Default)\n```bash\n# Make the script executable\nchmod +x use-local-state.sh\n\n# Switch to local state\n./use-local-state.sh\nterraform init\nterraform plan\n```\n\n#### Setting Up Remote State\n```bash\n# Make the scripts executable\nchmod +x create-backend.sh\nchmod +x use-remote-state.sh\n\n# Create the required AWS resources\n./create-backend.sh\n\n# Configure Terraform to use remote state\n./use-remote-state.sh\nterraform plan\n```\n\nYou can switch between local and remote state at any time using these scripts.\n\n## Modules\n\n### Network Module\n\nLocated in `modules/network`, this module creates:\n- VPC with public and private subnets\n- Internet Gateway for public internet access\n- NAT Gateway for private subnet internet access\n- Route tables for traffic routing\n\n### Security Module\n\nLocated in `modules/security`, this module creates:\n- Load balancer security group\n- ECS tasks security group\n- IAM roles for ECS task execution and task role\n\n### ECS Module\n\nLocated in `modules/ecs`, this module creates:\n- ECR repository for container images\n- ECS cluster\n- ECS task definition\n- ECS service\n\n## Application Description\n\nThis project deploys a Daily Task Manager application that helps users organize their daily activities. The application features:\n\n- Task creation, retrieval, updating, and deletion\n- Priority levels (1-5) for tasks\n- Due dates and completion status tracking\n- Web interface for viewing tasks\n- RESTful API for backend functionality\n\nThe application is built with FastAPI and uses HTML templates for the frontend views.\n\n## Running the Application Locally\n\n### Prerequisites\n- Python 3.9 or higher\n- pip (Python package manager)\n\n### Setup and Run\n1. Create a virtual environment (optional but recommended):\n   ```\n   python -m venv venv\n   ```\n\n2. Activate the virtual environment:\n   - Windows:\n     ```\n     venv\\Scripts\\activate\n     ```\n   - macOS/Linux:\n     ```\n     source venv/bin/activate\n     ```\n\n3. Install dependencies:\n   ```\n   pip install -r requirements.txt\n   ```\n\n4. Run the application:\n   ```\n   uvicorn app:app --reload\n   ```\n\n5. Access the API:\n   - Open your browser and navigate to http://localhost:8000\n   - API documentation is available at http://localhost:8000/docs\n\n### Using Docker\nAlternatively, you can run the application using Docker:\n\n```\ndocker build -t ecs-app .\ndocker run -p 8000:8000 ecs-app\n```\n\n## Infrastructure Usage\n\n```hcl\nmodule \"network\" {\n  source = \"./modules/network\"\n  \n  project_name      = var.project_name\n  vpc_cidr          = var.vpc_cidr\n  availability_zones = var.availability_zones\n}\n\nmodule \"security\" {\n  source = \"./modules/security\"\n  \n  project_name   = var.project_name\n  vpc_id         = module.network.vpc_id\n  container_port = var.container_port\n}\n\nmodule \"ecs\" {\n  source = \"./modules/ecs\"\n  \n  aws_region        = var.aws_region\n  project_name      = var.project_name\n  ecr_repository_name = var.ecr_repository_name\n  container_port    = var.container_port\n  container_cpu     = var.container_cpu\n  container_memory  = var.container_memory\n  app_count         = var.app_count\n  \n  ecs_task_execution_role_arn = module.security.ecs_task_execution_role_arn\n  ecs_task_role_arn           = module.security.ecs_task_role_arn\n  ecs_tasks_security_group_id = module.security.ecs_tasks_security_group_id\n  private_subnet_ids          = module.network.private_subnet_ids\n  \n  target_group_arn = module.alb.target_group_arn\n  lb_listener_arn  = module.alb.lb_listener_arn\n}\n```\n\n## Future Improvements\n\n- Create an ALB module to handle load balancer resources\n- Add CloudWatch logging module\n- Implement auto-scaling for ECS services\n\n## Architecture Diagram\n\n```\n+-------------------+\n|    Internet       |\n+-------------------+\n        |\n        v\n+-------------------+\n| Application Load  |\n|    Balancer (ALB) |\n+-------------------+\n        |\n        v\n+-------------------+\n| ECS Cluster       |\n| - ECS Service     |\n| - ECS Task        |\n+-------------------+\n        |\n        v\n+-------------------+\n| Private Subnets   |\n+-------------------+\n        |\n        v\n+-------------------+\n| ECR Repository    |\n+-------------------+\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftukue%2Fterraform-ecs-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftukue%2Fterraform-ecs-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftukue%2Fterraform-ecs-app/lists"}