{"id":21429606,"url":"https://github.com/dc-tec/terraform-aws-vpc","last_synced_at":"2026-01-03T16:10:04.475Z","repository":{"id":218428903,"uuid":"746367280","full_name":"dc-tec/terraform-aws-vpc","owner":"dc-tec","description":"Terraform AWS VPC Module","archived":false,"fork":false,"pushed_at":"2024-01-21T21:16:45.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T08:17:42.343Z","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/dc-tec.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":"docs/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-21T20:51:54.000Z","updated_at":"2024-01-21T21:16:16.000Z","dependencies_parsed_at":"2024-01-21T22:25:48.531Z","dependency_job_id":"4559b17b-bc36-452c-825e-28c78130eafd","html_url":"https://github.com/dc-tec/terraform-aws-vpc","commit_stats":null,"previous_names":["dc-tec/terraform-aws-vpc"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-vpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-vpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-vpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dc-tec%2Fterraform-aws-vpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dc-tec","download_url":"https://codeload.github.com/dc-tec/terraform-aws-vpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940062,"owners_count":20372044,"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":[],"created_at":"2024-11-22T22:18:28.163Z","updated_at":"2026-01-03T16:10:04.446Z","avatar_url":"https://github.com/dc-tec.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform AWS VPC module\n\nThis module manages the creation of a VPC, Subnets, Internet Gateway, NAT Gateway, Route Tables, Security Group and their associated rules on AWS.\n\n## Requirements\n\n- Terraform version 1.7.0 or newer\n- AWS provider version 5.0 or newer\n\n## Providers\n\n- AWS\n\n## Resources\n\n- `aws_vpc.main`: This resource creates a VPC.\n- `aws_subnet.main`: This resource creates subnets within the VPC.\n- `aws_internet_gateway.main`: This resource creates an internet gateway and attaches it to the VPC.\n- `aws_eip.main`: This resource creates an Elastic IP for the NAT Gateway.\n- `aws_nat_gateway.main`: This resource creates a NAT Gateway within the specified subnet.\n- `aws_route_table.main`: This resource creates a route table within the VPC.\n- `aws_route_table_association.main`: This resource associates subnets with the route table.\n- `aws_security_group.main`: This resource creates a security group within the VPC.\n- `aws_vpc_security_group_ingress_rule.main`: This resource creates ingress rules for the security group.\n- `aws_vpc_security_group_egress_rule.main`: This resource creates egress rules for the security group.\n- `aws_default_security_group.default`: This resource manages the default security group within the VPC.\n\n## Inputs\n\n- `vpc`: A map where each item represents a VPC.\n- `subnets`: A map where each item represents a subnet.\n- `internet_gateway`: A map where each item represents an internet gateway.\n- `nat_gateway`: A map where each item represents a NAT gateway.\n- `route_tables`: A map where each item represents a route table.\n- `route_table_associations`: A map where each item represents a route table association.\n- `security_groups`: A map where each item represents a security group.\n\n## Outputs\n\n- `vpc_ids`: The IDs of the created VPCs.\n- `subnet_ids`: The IDs of the created subnets.\n- `internet_gateway_ids`: The IDs of the created internet gateways.\n- `nat_gateway_ids`: The IDs of the created NAT gateways.\n- `route_table_ids`: The IDs of the created route tables.\n- `security_group_ids`: The IDs of the created security groups.\n\n## Example Usage\nThe module can be used in the following way:\n\n```hcl\nterraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp/aws\"\n      version = \"~\u003e 5.0\"\n    }\n  }\n  required_version = \"\u003e= 1.7.0\"\n}\n\nprovider \"aws\" {\n  region = var.region\n}\n\nlocals {\n  vpc_config = {\n    for vpc_name, vpc_info in var.vpc_config : vpc_name =\u003e {\n      cidr_block           = vpc_info.cidr_block\n      enable_dns           = coalesce(vpc_info.enable_dns, true)\n      enable_dns_hostnames = coalesce(vpc_info.enable_dns_hostnames, false)\n    }\n  }\n\n  sn_config = {\n    for sn_name, sn_info in var.sn_config : sn_name =\u003e {\n      vpc_name          = sn_info.vpc_name\n      cidr_block        = sn_info.cidr_block\n      availability_zone = sn_info.availability_zone\n    }\n  }\n\n  igw_config = {\n    for igw_name, igw_info in var.igw_config : igw_name =\u003e {\n      vpc_name = igw_info.vpc_name\n    }\n  }\n\n  ngw_config = {\n    for ngw_name, ngw_info in var.ngw_config : ngw_name =\u003e {\n      vpc_name    = ngw_info.vpc_name\n      subnet_name = ngw_info.subnet_name\n    }\n  }\n\n  rt_config = {\n    for rt_name, rt_info in var.rt_config : rt_name =\u003e {\n      vpc_name = rt_info.vpc_name\n      routes = [\n        for route_info in rt_info.routes : {\n          cidr_block = route_info.cidr_block\n          use_igw    = coalesce(route_info.use_igw, true)\n          igw_name   = coalesce(route_info.igw_name, \"default\")\n          use_ngw    = coalesce(route_info.use_ngw, false)\n          ngw_name   = coalesce(route_info.ngw_name, \"default\")\n        }\n      ]\n    }\n  }\n\n  rta_config = {\n    for rta_name, rta_info in var.rta_config : rta_name =\u003e {\n      subnet_name      = rta_info.subnet_name\n      route_table_name = rta_info.route_table_name\n    }\n  }\n\n  sg_config = {\n    for sg_name, sg_info in var.sg_config : sg_name =\u003e {\n      vpc_name = sg_info.vpc_name\n      ingress = {\n        for ingress_key, ingress_info in sg_info.ingress : ingress_key =\u003e {\n          from_port           = ingress_info.from_port\n          to_port             = ingress_info.to_port\n          protocol            = ingress_info.protocol\n          cidr_ipv4           = ingress_info.cidr_ipv4\n          security_group_name = ingress_info.security_group_name\n        }\n      }\n      egress = {\n        for egress_key, egress_info in sg_info.egress : egress_key =\u003e {\n          from_port           = egress_info.from_port\n          to_port             = egress_info.to_port\n          protocol            = egress_info.protocol\n          cidr_ipv4           = egress_info.cidr_ipv4\n          security_group_name = egress_info.security_group_name\n        }\n      }\n    }\n  }\n}\n\nmodule \"vpc\" {\n  source = \"src\"\n\n  ## VPC configuration\n  vpc                      = local.vpc_config\n  subnets                  = local.sn_config\n  internet_gateway         = local.igw_config\n  nat_gateway              = local.ngw_config\n  route_tables             = local.rt_config\n  route_table_associations = local.rta_config\n  security_groups          = local.sg_config\n\n}\n```\n\nThe following example TFVars can be used with this module.\n\n```hcl\nvpc_config = {\n  \"dev1\" = {\n    cidr_block           = \"10.0.0.0/16\"\n    enable_dns           = true\n    enable_dns_hostnames = false\n  }\n}\n\n## Subnet configuration\nsn_config = {\n  \"public1-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.1.0/24\"\n    availability_zone = \"eu-west-1a\"\n  },\n  \"public2-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.2.0/24\"\n    availability_zone = \"eu-west-1b\"\n  }\n  \"private1-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.10.0/24\"\n    availability_zone = \"eu-west-1a\"\n  },\n  \"private2-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.20.0/24\"\n    availability_zone = \"eu-west-1b\"\n  }\n  \"reserve1-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.100.0/24\"\n    availability_zone = \"eu-west-1a\"\n  },\n  \"reserve2-dev1\" = {\n    vpc_name          = \"dev1\"\n    cidr_block        = \"10.0.200.0/24\"\n    availability_zone = \"eu-west-1b\"\n  }\n}\n\n## Internet Gateway configuration\nigw_config = {\n  \"igw1-dev1\" = {\n    vpc_name = \"dev1\"\n  }\n}\n\n## Nat Gateway configuration\nngw_config = {\n  \"ngw1-dev1\" = {\n    vpc_name    = \"dev1\"\n    subnet_name = \"public1-dev1\"\n  }\n  \"ngw2-dev1\" = {\n    vpc_name    = \"dev1\"\n    subnet_name = \"public2-dev1\"\n  }\n}\n\n## Route Table configuration\nrt_config = {\n  \"rt1-dev1\" = {\n    vpc_name = \"dev1\"\n    routes = [\n      {\n        cidr_block = \"0.0.0.0/0\"\n        use_igw    = true\n        igw_name   = \"igw1-dev1\"\n        use_ngw    = false\n      }\n    ]\n  },\n  \"rt2-dev1\" = {\n    vpc_name = \"dev1\"\n    routes = [\n      {\n        cidr_block = \"0.0.0.0/0\"\n        use_igw    = false\n        use_ngw    = true\n        ngw_name   = \"ngw1-dev1\"\n      }\n    ]\n  },\n}\n\n## Route Table Association configuration      \nrta_config = {\n  \"rta1-dev1\" = {\n    subnet_name      = \"public1-dev1\"\n    route_table_name = \"rt1-dev1\"\n  }\n  \"rta2-dev1\" = {\n    subnet_name      = \"public2-dev1\"\n    route_table_name = \"rt1-dev1\"\n  }\n  \"rta3-dev1\" = {\n    subnet_name      = \"private1-dev1\"\n    route_table_name = \"rt2-dev1\"\n  }\n  \"rta4-dev1\" = {\n    subnet_name      = \"private2-dev1\"\n    route_table_name = \"rt2-dev1\"\n  }\n}\n\n## Security Group configuration\nsg_config = {\n  \"bastion-dev1\" = {\n    vpc_name = \"dev1\"\n    ingress = {\n      \"ssh\" = {\n        from_port = 22\n        to_port   = 22\n        protocol  = \"tcp\"\n        cidr_ipv4 = \"0.0.0.0/0\"\n      }\n    }\n    egress = {\n      \"http\" = {\n        from_port = 80\n        to_port   = 80\n        protocol  = \"tcp\"\n        cidr_ipv4 = \"0.0.0.0/0\"\n      },\n      \"https\" = {\n        from_port = 443\n        to_port   = 443\n        protocol  = \"tcp\"\n        cidr_ipv4 = \"0.0.0.0/0\"\n      },\n      \"ssh\" = {\n        from_port           = 22\n        to_port             = 22\n        protocol            = \"tcp\"\n        security_group_name = \"private-dev1\"\n      },\n    }\n  }\n  \"private-dev1\" = {\n    vpc_name = \"dev1\"\n    ingress = {\n      \"ssh\" = {\n        from_port           = 22\n        to_port             = 22\n        protocol            = \"tcp\"\n        security_group_name = \"bastion-dev1\"\n      }\n    }\n    egress = {\n      \"http\" = {\n        from_port = 80\n        to_port   = 80\n        protocol  = \"tcp\"\n        cidr_ipv4 = \"0.0.0.0/0\"\n      },\n      \"https\" = {\n        from_port = 443\n        to_port   = 443\n        protocol  = \"tcp\"\n        cidr_ipv4 = \"0.0.0.0/0\"\n      }\n    }\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdc-tec%2Fterraform-aws-vpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdc-tec%2Fterraform-aws-vpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdc-tec%2Fterraform-aws-vpc/lists"}