{"id":21202528,"url":"https://github.com/infrablocks/terraform-aws-base-networking","last_synced_at":"2025-07-10T06:33:09.317Z","repository":{"id":20264151,"uuid":"81815634","full_name":"infrablocks/terraform-aws-base-networking","owner":"infrablocks","description":"Terraform module for building base networking in AWS","archived":false,"fork":false,"pushed_at":"2023-12-11T13:50:43.000Z","size":1060,"stargazers_count":22,"open_issues_count":3,"forks_count":14,"subscribers_count":12,"default_branch":"main","last_synced_at":"2023-12-11T14:53:27.033Z","etag":null,"topics":["infrastructure","nat","private-subnets","public-subnets","subnet","subnets","terraform","terraform-modules","vpc"],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2017-02-13T11:00:06.000Z","updated_at":"2023-12-20T15:19:41.988Z","dependencies_parsed_at":"2023-02-14T07:45:19.676Z","dependency_job_id":"cf7fb29a-d549-4627-af34-ecbdeae0e5ce","html_url":"https://github.com/infrablocks/terraform-aws-base-networking","commit_stats":null,"previous_names":[],"tags_count":102,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-base-networking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-base-networking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-base-networking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infrablocks%2Fterraform-aws-base-networking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infrablocks","download_url":"https://codeload.github.com/infrablocks/terraform-aws-base-networking/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225622825,"owners_count":17498170,"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":["infrastructure","nat","private-subnets","public-subnets","subnet","subnets","terraform","terraform-modules","vpc"],"created_at":"2024-11-20T20:16:46.031Z","updated_at":"2024-11-20T20:16:46.654Z","avatar_url":"https://github.com/infrablocks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Terraform AWS Base Networking\n=============================\n\n[![Version](https://img.shields.io/github/v/tag/infrablocks/terraform-aws-base-networking?label=version\u0026sort=semver)](https://github.com/infrablocks/terraform-aws-base-networking/tags)\n[![Build Pipeline](https://img.shields.io/circleci/build/github/infrablocks/terraform-aws-base-networking/main?label=build-pipeline)](https://app.circleci.com/pipelines/github/infrablocks/terraform-aws-base-networking?filter=all)\n[![Maintainer](https://img.shields.io/badge/maintainer-go--atomic.io-red)](https://go-atomic.io)\n\nA Terraform module for building a base network in AWS.\n\nThe network consists of:\n\n* Public and private subnets for each supplied availability zone\n* A NAT gateway for each supplied availability zone for outbound Internet\n  connectivity\n* Routes from the public subnets to the Internet gateway\n* Routes from the private subnets to the NAT\n* Standard tags for all resources\n\n![Diagram of infrastructure managed by this module](https://raw.githubusercontent.com/infrablocks/terraform-aws-base-networking/main/docs/architecture.png)\n\nUsage\n-----\n\nTo use the module, include something like the following in your Terraform\nconfiguration:\n\n```terraform\nmodule \"base-network\" {\n  source  = \"infrablocks/base-networking/aws\"\n  version = \"4.0.0\"\n\n  vpc_cidr           = \"10.0.0.0/16\"\n  region             = \"eu-west-2\"\n  availability_zones = [\"eu-west-2a\", \"eu-west-2b\"]\n\n  component             = \"important-component\"\n  deployment_identifier = \"production\"\n\n  private_zone_id = \"Z3CVA9QD5NHSW3\"\n}\n```\n\nSee the\n[Terraform registry entry](https://registry.terraform.io/modules/infrablocks/base-networking/aws/latest)\nfor more details.\n\n### Inputs\n\n| Name                               | Description                                                                                   | Default |                     Required                     |\n|------------------------------------|-----------------------------------------------------------------------------------------------|:-------:|:------------------------------------------------:|\n| `vpc_cidr`                         | The CIDR to use for the VPC.                                                                  |    -    |                       Yes                        |\n| `region`                           | The region into which to deploy the VPC.                                                      |    -    |                       Yes                        |\n| `availability_zones`               | The availability zones for which to add subnets.                                              |    -    |                       Yes                        |\n| `public_subnets_offset`            | The number of /24s to offset the public subnets in the VPC CIDR.                              |   `0`   |                        No                        |\n| `private_subnets_offset`           | The number of /24s to offset the private subnets in the VPC CIDR.                             |   `0`   |                        No                        |\n| `component`                        | The component this network will contain.                                                      |    -    |                       Yes                        |\n| `deployment_identifier`            | An identifier for this instantiation.                                                         |    -    |                       Yes                        |\n| `dependencies`                     | A comma separated list of components depended on my this component.                           |  `[]`   |                        No                        |\n| `include_route53_zone_association` | Whether or not to associate VPC with the private Route 53 zone (`\"yes\"` or `\"no\"`).           | `\"yes\"` |                        No                        |\n| `private_zone_id`                  | The ID of the private Route 53 zone`                                                          |    -    | If `include_route53_zone_association` is `\"yes\"` |\n| `include_nat_gateways`             | Whether or not to deploy NAT gateways for outbound Internet connectivity (`\"yes\"` or `\"no\"`). | `\"yes\"` |                        No                        |\n\n### Outputs\n\n| Name                           | Description                                           |\n|--------------------------------|-------------------------------------------------------|\n| `vpc_id`                       | The ID of the created VPC.                            |\n| `vpc_cidr`                     | The CIDR of the created VPC.                          |\n| `availability_zones`           | The availability zones in which subnets were created. |\n| `number_of_availability_zones` | The number of populated availability zones available. |\n| `public_subnet_ids`            | The IDs of the public subnets.                        |\n| `public_subnet_cidrs`          | The CIDRs of the public subnets.                      |\n| `public_route_table_ids`       | The IDs of the public route tables.                   |\n| `private_subnet_ids`           | The IDs of the private subnets.                       |\n| `private_subnet_cidrs`         | The CIDRs of the private subnets.                     |\n| `private_route_table_ids`      | The IDs of the private route tables.                  |\n| `nat_public_ips`               | The EIPs attached to the NAT gateways.                |\n| `internet_gateway_id`          | The ID of the created IGW.                            |\n\n### Compatibility\n\nThis module is compatible with Terraform versions greater than or equal to \nTerraform 1.0 and Terraform AWS provider versions greater than or equal to 3.27.\n\n### Required Permissions\n\n* ec2:DescribeVpcs\n* ec2:DescribeAddresses\n* ec2:DescribeVpcAttribute\n* ec2:DescribeVpcClassicLink\n* ec2:DescribeVpcClassicLinkDnsSupport\n* ec2:DescribeRouteTables\n* ec2:DescribeSecurityGroups\n* ec2:DescribeNetworkAcls\n* ec2:DescribeSubnets\n* ec2:DescribeInternetGateways\n* ec2:DescribeNatGateways\n* ec2:ModifyVpcAttribute\n* ec2:AllocateAddress\n* ec2:ReleaseAddress\n* ec2:AssociateRouteTable\n* ec2:DisassociateRouteTable\n* ec2:AttachInternetGateway\n* ec2:DetachInternetGateway\n* ec2:DeleteInternetGateway\n* ec2:CreateRoute\n* ec2:CreateNatGateway\n* ec2:CreateVpc\n* ec2:CreateTags\n* ec2:CreateSubnet\n* ec2:CreateRouteTable\n* ec2:CreateInternetGateway\n* ec2:DeleteRoute\n* ec2:DeleteRouteTable\n* ec2:DeleteSubnet\n* ec2:DeleteNatGateway\n* ec2:DeleteVpc\n* s3:ListBucket\n* s3:GetObject\n* s3:GetObjectTagging\n* s3:DeleteObject\n* route53:AssociateVPCWithHostedZone\n* route53:DisassociateVPCFromHostedZone\n* route53:GetChange\n* route53:GetHostedZone\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)\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```shell\nruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n```\n\nThen, to install the required tools:\n\n```shell\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 run the full build, including unit and integration tests, execute:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go\n```\n\nTo run the unit tests, execute:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go test:unit\n```\n\nTo run the integration tests, execute:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go test:integration\n```\n\nTo provision the module prerequisites:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo provision the module contents:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:provision[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module contents:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go deployment:root:destroy[\u003cdeployment_identifier\u003e]\n```\n\nTo destroy the module prerequisites:\n\n```shell\naws-vault exec \u003cprofile\u003e -- ./go deployment:prerequisites:destroy[\u003cdeployment_identifier\u003e]\n```\n\nConfiguration parameters can be overridden via environment variables. For\nexample, to run the unit tests with a seed of `\"testing\"`, execute:\n\n```shell\nSEED=testing aws-vault exec \u003cprofile\u003e -- ./go test:unit\n```\n\nWhen a seed is provided via an environment variable, infrastructure will not be\ndestroyed at the end of test execution. This can be useful during development\nto avoid lengthy provision and destroy cycles.\n\nTo subsequently destroy unit test infrastructure for a given seed:\n\n```shell\nFORCE_DESTROY=yes SEED=testing aws-vault exec \u003cprofile\u003e -- ./go test:unit\n```\n\n### Common Tasks\n\n#### Generating an SSH key pair\n\nTo generate an SSH key pair:\n\n```shell\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```shell\nopenssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365\n```\n\nTo decrypt the resulting key:\n\n```shell\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```shell\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```shell\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-base-networking. This project is\nintended to be a safe, welcoming space for collaboration, and contributors are\nexpected 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-base-networking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfrablocks%2Fterraform-aws-base-networking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfrablocks%2Fterraform-aws-base-networking/lists"}