{"id":21202450,"url":"https://github.com/infrablocks/terraform-aws-network-load-balancer","last_synced_at":"2025-07-10T06:32:46.704Z","repository":{"id":38331595,"uuid":"192775575","full_name":"infrablocks/terraform-aws-network-load-balancer","owner":"infrablocks","description":"A Terraform module for building a network load balancer in AWS.","archived":false,"fork":false,"pushed_at":"2025-04-03T21:19:16.000Z","size":604,"stargazers_count":4,"open_issues_count":3,"forks_count":7,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-05T11:34:31.661Z","etag":null,"topics":["aws","aws-load-balancer","infrastructure","load-balancer","terraform","terraform-modules"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/infrablocks.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-06-19T17:21:34.000Z","updated_at":"2025-02-12T10:02:32.000Z","dependencies_parsed_at":"2024-07-18T11:54:03.932Z","dependency_job_id":"268f8103-e0a9-4ee6-95c5-fb1bd992fd3f","html_url":"https://github.com/infrablocks/terraform-aws-network-load-balancer","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/infrablocks/terraform-aws-network-load-balancer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-network-load-balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-network-load-balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-network-load-balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-network-load-balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infrablocks","download_url":"https://codeload.github.com/infrablocks/terraform-aws-network-load-balancer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-network-load-balancer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264538584,"owners_count":23624436,"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","aws-load-balancer","infrastructure","load-balancer","terraform","terraform-modules"],"created_at":"2024-11-20T20:16:01.444Z","updated_at":"2025-07-10T06:32:46.423Z","avatar_url":"https://github.com/infrablocks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Terraform AWS Network Load Balancer\n===================================\n\n[![CircleCI](https://circleci.com/gh/infrablocks/terraform-aws-network-load-balancer.svg?style=svg)](https://circleci.com/gh/infrablocks/terraform-aws-network-load-balancer)\n\nA Terraform module for building a network load balancer in AWS.\n\nThe load balancer requires:\n\n* An existing VPC\n* Some existing subnets\n* A domain name and public and private hosted zones\n\nThe ECS load balancer consists of:\n\n* An NLB\n    * Deployed across the provided subnet IDs\n    * Either internal or internet-facing as specified\n    * With a health check using the specified target\n    * With connection draining as specified\n* A security group allowing access to/from the load balancer according to the\n  specified access control and egress CIDRs configuration\n* A security group for use by instances allowing access from the load balancer\n  according to the specified access control configuration\n* A DNS entry\n    * In the public hosted zone if specified\n    * In the private hosted zone if specified\n\n![Diagram of infrastructure managed by this module](https://raw.githubusercontent.com/infrablocks/terraform-aws-network-load-balancer/main/docs/architecture.png)\n\nUsage\n-----\n\nTo use the module, include something like the following in your Terraform\nconfiguration:\n\n```hcl-terraform\nmodule \"network_load_balancer\" {\n  source  = \"infrablocks/network-load-balancer/aws\"\n  version = \"0.1.7\"\n\n  region     = \"eu-west-2\"\n  vpc_id     = \"vpc-fb7dc365\"\n  subnet_ids = \"subnet-ae4533c4,subnet-443e6b12\"\n\n  component             = \"important-component\"\n  deployment_identifier = \"production\"\n\n  domain_name     = \"example.com\"\n  public_zone_id  = \"Z1WA3EVJBXSQ2V\"\n  private_zone_id = \"Z3CVA9QD5NHSW3\"\n\n  listeners = [\n    {\n      lb_port            = 443\n      lb_protocol        = \"HTTPS\"\n      instance_port      = 443\n      instance_protocol  = \"HTTPS\"\n      ssl_certificate_id = \"arn:aws:iam::123456789012:server-certificate/default\"\n    },\n    {\n      lb_port           = 6567\n      lb_protocol       = \"TCP\"\n      instance_port     = 6567\n      instance_protocol = \"TCP\"\n    }\n  ]\n\n  access_control = [\n    {\n      lb_port       = 443\n      instance_port = 443\n      allow_cidr    = '0.0.0.0/0'\n    },\n    {\n      lb_port       = 6567\n      instance_port = 6567\n      allow_cidr    = '10.0.0.0/8'\n    }\n  ]\n\n  egress_cidrs = '10.0.0.0/8'\n\n  health_check_target              = 'HTTPS:443/ping'\n  health_check_timeout             = 10\n  health_check_interval            = 30\n  health_check_unhealthy_threshold = 5\n  health_check_healthy_threshold   = 5\n\n  enable_cross_zone_load_balancing = 'yes'\n\n  enable_connection_draining  = 'yes'\n  connection_draining_timeout = 60\n\n  idle_timeout = 60\n\n  include_public_dns_record  = 'yes'\n  include_private_dns_record = 'yes'\n\n  expose_to_public_internet = 'yes'\n}\n```\n\nAs mentioned above, the load balancer deploys into an existing base network.\nWhilst the base network can be created using any mechanism you like, the\n[AWS Base Networking](https://github.com/infrablocks/terraform-aws-base-networking)\nmodule will create everything you need. See the\n[docs](https://github.com/infrablocks/terraform-aws-base-networking/blob/main/README.md)\nfor usage instructions.\n\nSee the\n[Terraform registry entry](https://registry.terraform.io/modules/infrablocks/network-load-balancer/aws/latest)\nfor more details.\n\n### Inputs\n\n| Name                             | Description                                                                                                                            |   Default    | Required |\n|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|:------------:|:--------:|\n| region                           | The region into which to deploy the load balancer                                                                                      |      -       |   yes    |\n| vpc_id                           | The ID of the VPC into which to deploy the load balancer\t                                                                              |      -       |   yes    |\n| subnet_ids                       | The IDs of the subnets for the NLB\t                                                                                                    |      -       |   yes    |\n| component                        | The component for which the load balancer is being created\t                                                                            |      -       |   yes    |\n| deployment_identifier            | An identifier for this instantiation\t                                                                                                  |      -       |   yes    |\n| domain_name                      | The domain name of the supplied Route 53 zones                                                                                         |      -       |   yes    |\n| public_zone_id                   | The ID of the public Route 53 zone\t                                                                                                    |      -       |   yes    |\n| private_zone_id                  | The ID of the private Route 53 zone\t                                                                                                   |      -       |   yes    |\n| enable_cross_zone_load_balancing | Whether or not to enable cross zone load balancing (\\\"yes\\\" or \\\"no\\\").                                                                |      no      |    no    |\n| enable_deletion_protection       | Whether or not to enable deletion protection for the load balancer.                                                                    |    false     |    no    |\n| enable_access_logs               | Whether or not to enable access logs on the load balancer.                                                                             |    false     |    no    |\n| access_logs_bucket_name          | The name of the S3 bucket in which to store access logs when `enable_access_logs` is `true`.                                           |    false     |    no    |\n| access_logs_bucket_prefix        | The prefix to use for objects in the access logs S3 bucket when `enable_access_logs` is `true`. Logs are stored in the root if `null`. |    false     |    no    |\n| idle_timeout                     | The time after which idle connections are closed.                                                                                      |      60      |    no    |\n| include_public_dns_record        | Whether or not to create a public DNS entry (\\\"yes\\\" or \\\"no\\\").                                                                       |      no      |    no    |\n| include_private_dns_record       | Whether or not to create a private DNS entry (\\\"yes\\\" or \\\"no\\\").                                                                      |     yes      |    no    |\n| expose_to_public_internet        | Whether or not to the NLB should be internet facing (\\\"yes\\\" or \\\"no\\\").                                                               |      no      |    no    |\n| use_https                        | whether or not to use HTTPS                                                                                                            |      no      |    no    |\n| target_group_port                | The port that the application is listening on                                                                                          |      -       |   yes    |\n| target_group_type                | The type of target that you must specify when registering targets with this target group.                                              |   instance   |    no    |\n| target_group_protocol            | The protocol to use for routing traffic to the targets. Should be either TCP or TLS                                                    |     TCP      |    no    |\n| health_check_port                | The port to use to connect with the target. Either ports 1-65536, or traffic-port                                                      | traffic-port |    no    |\n| health_check_protocol            | The protocol to use for health checks\t                                                                                                 |     TLS      |    no    |\n| health_check_interval            | The time between health check attempts in seconds\t                                                                                     |      30      |    no    |\n| health_check_unhealthy_threshold | The number of failed health checks before an instance is taken out of service\t                                                         |      2       |    no    |\n| health_check_healthy_threshold   | The number of successful health checks before an instance is put into service\t                                                         |      10      |    no    |\n| listener_port                    | Port that NLB listens on                                                                                                               |     443      |    no    |\n| listener_protocol                | Protocol that the NLB listens on                                                                                                       |     TLS      |    no    |\n| listener_certificate_arn         | certificate ARN to be used by the certificate                                                                                          |      -       |   yes    |\n\n### Outputs\n\n| Name     | Description                                          |\n|----------|------------------------------------------------------|\n| name     | The name of the created NLB                          |\n| arn      | The arn of the created NLB                           |\n| zone_id  | The zone ID of the created NLB                       |\n| dns_name | The DNS name of the created NLB                      |\n| address  | The address of the DNS record(s) for the created NLB |\n\n### Compatibility\n\nThis module is compatible with Terraform versions greater than or equal to\nTerraform 1.3.\n\nDevelopment\n-----------\n\n### Machine Requirements\n\nIn order for the build to run correctly, a few tools will need to be installed\non your development machine:\n\n* Ruby (3.1.1)\n* Bundler\n* git\n* git-crypt\n* gnupg\n* direnv\n* aws-vault\n\n#### Mac OS X Setup\n\nInstalling the required tools is best managed by [homebrew](http://brew.sh).\n\nTo install homebrew:\n\n```\nruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\nThen, to install the required tools:\n\n```\n# ruby\nbrew install rbenv\nbrew install ruby-build\necho 'eval \"$(rbenv init - bash)\"' \u003e\u003e ~/.bash_profile\necho 'eval \"$(rbenv init - zsh)\"' \u003e\u003e ~/.zshrc\neval \"$(rbenv init -)\"\nrbenv install 3.1.1\nrbenv rehash\nrbenv local 3.1.1\ngem install bundler\n\n# git, git-crypt, gnupg\nbrew install git\nbrew install git-crypt\nbrew install gnupg\n\n# aws-vault\nbrew cask install\n\n# direnv\nbrew install direnv\necho \"$(direnv hook bash)\" \u003e\u003e ~/.bash_profile\necho \"$(direnv hook zsh)\" \u003e\u003e ~/.zshrc\neval \"$(direnv hook $SHELL)\"\n\ndirenv allow \u003crepository-directory\u003e\n```\n\n### Running the build\n\nRunning the build requires an AWS account and AWS credentials. You are free to\nconfigure credentials however you like as long as an access key ID and secret\naccess key are available. These instructions utilise\n[aws-vault](https://github.com/99designs/aws-vault) which makes credential\nmanagement easy and secure.\n\nTo provision module infrastructure, run tests and then destroy that\ninfrastructure, execute:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go\n```\n\nTo provision the module prerequisites:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo provision the module contents:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module contents:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:destroy[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module prerequisites:\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:destroy[\u003cdeployment_identifier\u003e]\n```\n\nConfiguration parameters can be overridden via environment variables:\n\n```bash\nDEPLOYMENT_IDENTIFIER=testing aws-vault exec \u003cprofile\u003e -- ./go\n```\n\nWhen a deployment identifier is provided via an environment variable,\ninfrastructure will not be destroyed at the end of test execution. This can\nbe useful during development to avoid lengthy provision and destroy cycles.\n\nBy default, providers will be downloaded for each terraform execution. To\ncache providers between calls:\n\n```bash\nTF_PLUGIN_CACHE_DIR=\"$HOME/.terraform.d/plugin-cache\" aws-vault exec \u003cprofile\u003e -- ./go\n```\n\n### Common Tasks\n\n#### Generating an SSH key pair\n\nTo generate an SSH key pair:\n\n```\nssh-keygen -m PEM -t rsa -b 4096 -C integration-test@example.com -N '' -f config/secrets/keys/bastion/ssh\n```\n\n#### Generating a self-signed certificate\n\nTo generate a self signed certificate:\n\n```\nopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365\n```\n\nTo decrypt the resulting key:\n\n```\nopenssl rsa -in key.pem -out ssl.key\n```\n\n#### Managing CircleCI keys\n\nTo encrypt a GPG key for use by CircleCI:\n\n```bash\nopenssl aes-256-cbc \\\n  -e \\\n  -md sha1 \\\n  -in ./config/secrets/ci/gpg.private \\\n  -out ./.circleci/gpg.private.enc \\\n  -k \"\u003cpassphrase\u003e\"\n```\n\nTo check decryption is working correctly:\n\n```bash\nopenssl aes-256-cbc \\\n  -d \\\n  -md sha1 \\\n  -in ./.circleci/gpg.private.enc \\\n  -k \"\u003cpassphrase\u003e\"\n```\n\nContributing\n------------\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/infrablocks/terraform-aws-network-load-balancer. This project\nis intended to be a safe, welcoming space for collaboration, and contributors\nare expected to adhere to the\n[Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nLicense\n-------\n\nThe library is available as open source under the terms of the\n[MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrablocks%2Fterraform-aws-network-load-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfrablocks%2Fterraform-aws-network-load-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrablocks%2Fterraform-aws-network-load-balancer/lists"}