{"id":15652460,"url":"https://github.com/mattyait/devops_terraform","last_synced_at":"2025-10-27T22:34:08.285Z","repository":{"id":81852523,"uuid":"134045203","full_name":"mattyait/devops_terraform","owner":"mattyait","description":"Repository to provision the infrastructure on AWS using Terraform","archived":false,"fork":false,"pushed_at":"2024-10-21T02:15:50.000Z","size":168,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T20:08:19.572Z","etag":null,"topics":["devops","ecs-service","eks","infrastructure","infrastucture-as-code","terraform"],"latest_commit_sha":null,"homepage":null,"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/mattyait.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}},"created_at":"2018-05-19T08:42:00.000Z","updated_at":"2024-10-21T02:15:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"259a8fb7-ce26-49bc-a649-29aeaebce613","html_url":"https://github.com/mattyait/devops_terraform","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mattyait/devops_terraform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyait%2Fdevops_terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyait%2Fdevops_terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyait%2Fdevops_terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyait%2Fdevops_terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattyait","download_url":"https://codeload.github.com/mattyait/devops_terraform/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattyait%2Fdevops_terraform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281355380,"owners_count":26486897,"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-10-27T02:00:05.855Z","response_time":61,"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":["devops","ecs-service","eks","infrastructure","infrastucture-as-code","terraform"],"created_at":"2024-10-03T12:42:26.360Z","updated_at":"2025-10-27T22:34:08.256Z","avatar_url":"https://github.com/mattyait.png","language":"HCL","readme":"[![Build Status](https://travis-ci.org/mattyait/devops_terraform.svg?branch=master)](https://travis-ci.org/mattyait/devops_terraform)\n# devops_terraform\n\nBuild the docker image\n\n    docker build -t terraform/devops_terraform:latest -f Dockerfile .\n\nRun the docker container\n\n    docker run -i -d -v $(pwd):/mnt/workspace terraform/devops_terraform:latest\n\nEnter the Container and use it as a Dev Environment\n\n    docker exec -it $(docker ps | grep devops_terraform:latest | awk '{print $1}') bash\n\nSetup the AWS Credentials\n\n    aws configure\n    AWS Access Key ID [None]: *********\n    AWS Secret Access Key [None]: **********\n    Default region name [None]:\n    Default output format [Noµne]:\n\n# Customize way of handling multiple environment for this project structure\n\nterraform is using S3 as backend so create a s3 bucket used in backend variable file: `test.backend.tfvar`\nCd into the specific environment folder and run the terraform\n\n    cd devops_terraform/env/test\n    terraform init -reconfigure -var-file=test.variables.tfvar -backend-config=test.backend.tfvar ../../deployment/\n    terraform plan -var-file=test.variables.tfvar ../../deployment\n    terraform apply -var-file=test.variables.tfvar ../../deployment\n\nRun specific module\n\n    terraform plan -var-file=test.variables.tfvar -target=module.\u003cmodule_name\u003e ../../deployment/\n\n## Disable/Skip specific part of infra while terraform apply\nTo disbale or avoid the execution of any specific terraform file, currenlty need to pass the toggle off/on variable in `test.variables.tfvar` to control the specific part of infra.\nFor example, below are used to skip the ecs_cluster,ecs_service and codebuild part of infra.\n\n    ecs_cluster_create  = \"false\"\n    ecs_service_create  = \"false\"\n    codebuild_create    = \"false\"\n\n\n## General way using terraform\nAfter Setup the Credentials, Initialize the terraform and execute the plan\n\n        terraform fmt\n        terraform init\n        terraform plan\n\nTo Create the Infrastructure apply the terraform changes\n\n        terraform apply\n\n## Terraform way of handling Multiple Environment\nCreate the multiple workspace in case of handling the multiple env.\n\n    terraform workspace new dev\n\nTo list and Select the specification workspace\n\n    terraform workspace list\n    terraform workspace select dev\n\n\n\n# To destory the created infratstructure\n\n    terraform destroy -var-file=test.variable.tfvars ../../deployment\n\n## Modules\n- **vpc** : This is a module to create VPC, Private and all public subnets\n- **subnet** : This is use to create subnet resource\n- **security_group**: Module use to create security group with security rules\n- **route_table**: Module to create route table entry\n- **nat_gateway**: module to create nat gateway\n- **internet_gateway**: Module to create internet_gateway\n- **alb_loadbalancer** : Module for any type of load balancer with listerner and target group\n- **alb_target_grp**: Module to create the target group for ALB\n- **ecs_cluster**: Module to create ecs cluster with security group, launch configuration and autoscaling group\n- **ecs_service**: Module to create full ecs service with task definition and attach to ecs cluster\n\n## Usage\n\n# Security group\n\n    module \"ecs_cluster_security_group\" {\n      source              = \"../../modules/aws/network/security_group\"\n      security_group_name = \"${var.ecs_security_group_name}\"\n      vpc_id              = \"${module.vpc.vpc_id_out}\"\n      environment         = \"${var.environment}\"\n      description         = \"ecs_cluster_sg\"\n      ingress_cidr_blocks = [\n        {\n            from_port   = 80\n            to_port     = 80\n            protocol    = \"tcp\"\n            description = \"ssh port open\"\n            cidr_blocks = [\"0.0.0.0/0\"]\n        },\n        {\n            from_port   = 8080\n            to_port     = 8080\n            protocol    = \"tcp\"\n            description = \"Application port\"\n            cidr_blocks = [\"0.0.0.0/0\"]\n        }\n      ]\n\n      egress_cidr_blocks    =  [\n        {\n            from_port   = 0\n            to_port     = 0\n            protocol    = \"-1\"\n            description = \"Allow outgoing traffic\"\n            cidr_blocks = [\"0.0.0.0/0\"]\n        }\n      ]\n    }\n\n# Alb load balancer\n\n    module \"ecs_alb_loadbalancer\" {\n      source                            = \"../../modules/aws/compute/alb_loadbalancer\"\n      lb_name                           = \"test\"\n      is_internal_lb                    = \"false\"\n      load_balancer_type                = \"application\"\n      security_groups                   = [\"${module.ecs_alb_security_group.security_group_id_out}\"]\n      subnets                           = [\"${module.private_subnet_1a.subnet_id_out}\",\"${module.private_subnet_1b.subnet_id_out}\"]\n      deletion_protection               = \"false\"\n      alb_target_group_name             = \"test\"\n      environment                       = \"${var.environment}\"\n      type                              = \"ecs_alb\"\n\n      #Target Group related parameters\n      vpc_id                             =  \"${module.vpc.vpc_id_out}\"\n      target_group_port                  = \"80\"\n      target_group_protocol              = \"HTTP\"\n    }\n\n# Ecs cluster\n\n    module \"app_ecs_cluster\" {\n      source            = \"../../modules/aws/compute/ecs_cluster\"    \n      ecs_cluster_name  = \"${var.ecs_cluster_name}\"\n      vpc_id              = \"${module.vpc.vpc_id_out}\"\n      environment       = \"${var.environment}\"\n      image_id          = \"${var.ecs_ec2_ami}\"\n      instance_type     = \"${var.ecs_ec2_instance_type}\"\n      subnet_ids       = [\"${module.private_subnet_1a.subnet_id_out},${module.private_subnet_1b.subnet_id_out}\"]\n      desired_capacity = \"${var.ecs_ec2_desired_capacity}\"\n      max_size         = \"${var.ecs_ec2_max_size}\"\n      min_size         = \"${var.ecs_ec2_min_size}\"\n      key_name         =  \"${var.key_name}\"\n      root_volume_size  = \"20\"\n      ebs_volume_size   = \"50\"\n      security_group_ids = [\"${module.ecs_cluster_security_group.security_group_id_out}\"]\n    }\n\n# Ecs service example\n\n    module \"app_ecs_service\" {\n      source                        = \"../../modules/aws/compute/ecs_service\"\n      name                          = \"test\"\n      environment                   = \"${var.environment}\"\n      ecs_cluster_arn               = \"${module.app_ecs_cluster.ecs_cluster_arn_out}\"\n      ecs_vpc_id                    = \"${module.vpc.vpc_id_out}\"\n      ecs_subnet_ids                = [\"${module.private_subnet_1a.subnet_id_out}\",\"${module.private_subnet_1b.subnet_id_out}\"]\n      tasks_desired_count           = 2\n      tasks_minimum_healthy_percent = 50\n      tasks_maximum_percent         = 200\n      associate_alb                 = true\n      alb_security_group            = \"${module.ecs_alb_security_group.security_group_id_out}\"\n      lb_target_group               = \"${module.ecs_alb_loadbalancer.alb_target_group_id_out}\"\n\n      #Autoscaling parameters\n      cluster_name                   = \"${module.app_ecs_cluster.ecs_cluster_name_out}\"\n      desired_count                  = \"${var.ecs_asg_desired_count}\"\n      min_count                      = \"${var.ecs_asg_min_count}\"\n      max_count                      = \"${var.ecs_asg_max_count}\"\n      scale_up_cooldown_seconds      = \"${var.ecs_scale_up_cooldown_seconds}\"\n      scale_down_cooldown_seconds    = \"${var.ecs_scale_down_cooldown_seconds}\"\n    }\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyait%2Fdevops_terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattyait%2Fdevops_terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattyait%2Fdevops_terraform/lists"}