|
8 | 8 | <p>Returns descriptive information about an Amazon VPC</p> |
9 | 9 | </div> |
10 | 10 |
|
| 11 | +## Purpose |
| 12 | + |
| 13 | +This module is considered to be a [data-only](https://www.terraform.io/docs/language/modules/develop/composition.html#data-only-modules) module. Given the name of a VPC and an optional set of availability zones, this module returns information about a VPC, such as public and private subnets, the VPC ID, etc. See the [outputs](outputs.tf) file for which data is returned from this module. This module is useful for workspaces that require such information without declaring repetitive `data` sources in your Terraform configurations. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +The following example creates a security group and an application load balancer. |
| 18 | + |
| 19 | +```hcl |
| 20 | +provider "aws" {} |
| 21 | +
|
| 22 | +module "networking" { |
| 23 | + source = "github.com/mongodb-ansible-roles/terraform-aws-networking-readonly" |
| 24 | + version = "1.1.0" |
| 25 | +
|
| 26 | + vpc_name = "tutorial-vpc" |
| 27 | +} |
| 28 | +
|
| 29 | +resource "aws_security_group" "this" { |
| 30 | + ingress = [ |
| 31 | + { |
| 32 | + cidr_blocks = ["0.0.0.0/0"] |
| 33 | + from_port = 443 |
| 34 | + protocol = "TCP" |
| 35 | + to_port = 443 |
| 36 | + } |
| 37 | + ] |
| 38 | +
|
| 39 | + vpc_id = module.networking.vpc_id |
| 40 | +} |
| 41 | +
|
| 42 | +resource "aws_lb" "this" { |
| 43 | + internal = false |
| 44 | + load_balancer_type = "application" |
| 45 | + security_groups = [aws_security_group.this.id] |
| 46 | + subnets = module.networking.public_subnets |
| 47 | +} |
| 48 | +``` |
| 49 | + |
11 | 50 | <!-- BEGIN_TF_DOCS --> |
| 51 | + |
| 52 | +## Requirements |
| 53 | + |
| 54 | +| Name | Version | |
| 55 | +| ------------------------------------------------------------------------ | --------- | |
| 56 | +| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | >= 1.0 | |
| 57 | +| <a name="requirement_aws"></a> [aws](#requirement_aws) | >= 3.64.2 | |
| 58 | + |
| 59 | +## Providers |
| 60 | + |
| 61 | +| Name | Version | |
| 62 | +| ------------------------------------------------ | ------- | |
| 63 | +| <a name="provider_aws"></a> [aws](#provider_aws) | 3.70.0 | |
| 64 | + |
| 65 | +## Modules |
| 66 | + |
| 67 | +No modules. |
| 68 | + |
| 69 | +## Resources |
| 70 | + |
| 71 | +| Name | Type | |
| 72 | +| -------------------------------------------------------------------------------------------------------------------------------- | ----------- | |
| 73 | +| [aws_availability_zones.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source | |
| 74 | +| [aws_subnet.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source | |
| 75 | +| [aws_subnet_ids.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source | |
| 76 | +| [aws_vpc.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source | |
| 77 | + |
| 78 | +## Inputs |
| 79 | + |
| 80 | +| Name | Description | Type | Default | Required | |
| 81 | +| --------------------------------------------------------------------------------------- | ------------------------------------ | ------------- | ------- | :------: | |
| 82 | +| <a name="input_availability_zones"></a> [availability_zones](#input_availability_zones) | Select subnets only in the given AZs | `set(string)` | `[]` | no | |
| 83 | +| <a name="input_vpc_name"></a> [vpc_name](#input_vpc_name) | The name of the VPC | `string` | n/a | yes | |
| 84 | + |
| 85 | +## Outputs |
| 86 | + |
| 87 | +| Name | Description | |
| 88 | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | |
| 89 | +| <a name="output_dns_hostnames_enabled"></a> [dns_hostnames_enabled](#output_dns_hostnames_enabled) | Indicates if instances launched in this VPC will have public DNS hostnames | |
| 90 | +| <a name="output_dns_support_enabled"></a> [dns_support_enabled](#output_dns_support_enabled) | Indicates if DNS support is enabled for this VPC | |
| 91 | +| <a name="output_private_subnets"></a> [private_subnets](#output_private_subnets) | List of private subnets in this VPC | |
| 92 | +| <a name="output_public_subnets"></a> [public_subnets](#output_public_subnets) | List of public subnets in this VPC | |
| 93 | +| <a name="output_vpc_arn"></a> [vpc_arn](#output_vpc_arn) | Arn of this VPC | |
| 94 | +| <a name="output_vpc_cidr_block"></a> [vpc_cidr_block](#output_vpc_cidr_block) | CIDR range for this VPC | |
| 95 | +| <a name="output_vpc_id"></a> [vpc_id](#output_vpc_id) | The ID of the VPC | |
| 96 | + |
12 | 97 | <!-- END_TF_DOCS --> |
13 | 98 |
|
14 | 99 | ## Contributing |
|
0 commit comments