{"id":29353732,"url":"https://github.com/shivanshu814/terrazenith","last_synced_at":"2026-05-10T02:09:29.603Z","repository":{"id":303331491,"uuid":"1015108557","full_name":"shivanshu814/TerraZenith","owner":"shivanshu814","description":"Peak Terraform infrastructure for ECS deployment. Complete AWS ECS setup with Fargate, Application Load Balancer, auto-scaling, and CloudWatch monitoring. Production-ready infrastructure as code with Docker containerization.","archived":false,"fork":false,"pushed_at":"2025-07-07T03:17:29.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T04:28:39.940Z","etag":null,"topics":["aws","devops","docker","ecs","load-balancer","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/shivanshu814.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-07-07T02:47:30.000Z","updated_at":"2025-07-07T03:18:52.000Z","dependencies_parsed_at":"2025-07-07T04:29:08.243Z","dependency_job_id":"5f1862f8-6bd1-45e8-bd3c-4289f0a340fd","html_url":"https://github.com/shivanshu814/TerraZenith","commit_stats":null,"previous_names":["shivanshu814/terra-zenith"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shivanshu814/TerraZenith","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivanshu814%2FTerraZenith","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivanshu814%2FTerraZenith/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivanshu814%2FTerraZenith/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivanshu814%2FTerraZenith/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shivanshu814","download_url":"https://codeload.github.com/shivanshu814/TerraZenith/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivanshu814%2FTerraZenith/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264379216,"owners_count":23598824,"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","devops","docker","ecs","load-balancer","terraform"],"created_at":"2025-07-09T02:09:04.313Z","updated_at":"2026-05-10T02:09:29.572Z","avatar_url":"https://github.com/shivanshu814.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ECS Terraform Infrastructure with Docker\n\nComplete AWS ECS infrastructure deployment using Terraform with Docker containerization.\n\n## Project Structure\n\n```\nterraform-learn/\n├── Dockerfile              # Node.js application Dockerfile\n├── Dockerfile.simple       # Nginx-based Dockerfile (recommended)\n├── nginx.conf             # Nginx configuration\n├── public/\n│   └── index.html         # Web application\n├── terraform/\n│   ├── main.tf           # Main Terraform configuration\n│   ├── variables.tf      # Variable definitions\n│   ├── terraform.tfvars  # Variable values\n│   ├── deploy.sh         # Deployment script\n│   └── README.md         # Terraform documentation\n├── build-and-push.sh     # Docker build and push script\n└── .dockerignore         # Docker ignore file\n```\n\n## Quick Start\n\n### Prerequisites\n\n- AWS CLI configured\n- Terraform installed\n- Docker installed\n- AWS credentials with ECR permissions\n\n### Step 1: Build and Push Docker Image\n\n```bash\n./build-and-push.sh\n```\n\n### Step 2: Deploy Infrastructure\n\n```bash\ncd terraform\n./deploy.sh\n```\n\n### Step 3: Access Your Application\n\nAfter deployment, access your application using the ALB DNS name:\n\n```bash\nterraform output alb_dns_name\n```\n\n## Docker Setup\n\n### Option 1: Simple Nginx Application (Recommended)\n\n```bash\n# Build using simple Dockerfile\ndocker build -f Dockerfile.simple -t ecs-demo-app .\n\n# Run locally to test\ndocker run -p 8080:80 ecs-demo-app\n```\n\n### Option 2: Node.js Application\n\n```bash\n# Build using Node.js Dockerfile\ndocker build -f Dockerfile -t ecs-demo-app .\n\n# Run locally to test\ndocker run -p 3000:3000 ecs-demo-app\n```\n\n## Infrastructure Components\n\n### Created Resources:\n\n- **VPC** with public/private subnets\n- **Application Load Balancer** (ALB)\n- **ECS Cluster** with Fargate\n- **ECS Task Definition** and **Service**\n- **Security Groups** and **IAM Roles**\n- **CloudWatch Log Group**\n- **ECR Repository** (created automatically)\n\n### Architecture:\n\n```\nInternet → ALB → ECS Service → ECS Tasks (Fargate)\n```\n\n## Customization\n\n### Docker Image\n\nEdit `Dockerfile.simple` to customize your application:\n\n```dockerfile\n# Change base image\nFROM nginx:alpine\n\n# Add custom files\nCOPY your-app/ /usr/share/nginx/html/\n```\n\n### Terraform Configuration\n\nModify `terraform/terraform.tfvars`:\n\n```hcl\n# Change region\naws_region = \"us-west-2\"\n\n# Adjust resources\ntask_cpu = 512\ntask_memory = 1024\nservice_desired_count = 3\n```\n\n## Monitoring\n\n### CloudWatch Logs\n\n```bash\n# View container logs\naws logs describe-log-groups --log-group-name-prefix \"/ecs/ecs-app\"\n```\n\n### ECS Service Status\n\n```bash\n# Check service status\naws ecs describe-services --cluster ecs-app-cluster --services ecs-app-service\n```\n\n### ALB Health\n\n```bash\n# Check target health\naws elbv2 describe-target-health --target-group-arn \u003ctarget-group-arn\u003e\n```\n\n## Development Workflow\n\n### 1. Local Development\n\n```bash\n# Build and test locally\ndocker build -f Dockerfile.simple -t my-app .\ndocker run -p 8080:80 my-app\n```\n\n### 2. Push to ECR\n\n```bash\n# Build and push to ECR\n./build-and-push.sh\n```\n\n### 3. Deploy Infrastructure\n\n```bash\n# Deploy with Terraform\ncd terraform\nterraform apply\n```\n\n### 4. Update Application\n\n```bash\n# After code changes\n./build-and-push.sh\n# Terraform will use the new image automatically\n```\n\n## Cost Optimization\n\n- **Fargate**: Pay only for what you use\n- **Minimal Resources**: 256 CPU, 512MB RAM by default\n- **Auto Scaling**: Scale based on demand\n- **Spot Instances**: Use for non-critical workloads\n\n## Security Features\n\n- **Private Subnets**: ECS tasks run in private subnets\n- **Security Groups**: Restrict traffic to HTTP/HTTPS\n- **IAM Roles**: Least privilege access\n- **Container Logging**: All logs sent to CloudWatch\n\n## Cleanup\n\n### Destroy Infrastructure\n\n```bash\ncd terraform\nterraform destroy\n```\n\n### Remove ECR Repository\n\n```bash\naws ecr delete-repository --repository-name ecs-demo-app --force\n```\n\n## Troubleshooting\n\n### Common Issues:\n\n1. **Docker Build Fails**\n\n   ```bash\n   # Check Docker is running\n   docker --version\n   docker ps\n   ```\n\n2. **ECR Login Issues**\n\n   ```bash\n   # Re-login to ECR\n   aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin \u003caccount-id\u003e.dkr.ecr.us-east-1.amazonaws.com\n   ```\n\n3. **Terraform Apply Fails**\n\n   ```bash\n   # Check AWS credentials\n   aws sts get-caller-identity\n\n   # Check Terraform state\n   terraform plan\n   ```\n\n4. **ECS Service Not Starting**\n   ```bash\n   # Check service events\n   aws ecs describe-services --cluster ecs-app-cluster --services ecs-app-service --query 'services[0].events'\n   ```\n\n## Next Steps\n\nConsider adding:\n\n- HTTPS/SSL certificates\n- Custom domain names\n- Auto scaling policies\n- CI/CD pipeline integration\n- Monitoring and alerting\n- Blue-green deployments\n\n## Success!\n\nAfter deployment, you'll have:\n\n- **Production-ready ECS cluster**\n- **Scalable containerized application**\n- **Load balancer for traffic distribution**\n- **CloudWatch monitoring**\n- **Infrastructure as Code**\n\nYour application will be available at the ALB DNS name!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivanshu814%2Fterrazenith","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshivanshu814%2Fterrazenith","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivanshu814%2Fterrazenith/lists"}