Skip to content

mongodb-devprod-infrastructure/terraform-aws-networking-data-only

Repository files navigation

terraform-aws-networking-data-only

Returns descriptive information about an Amazon VPC

Purpose

This module is considered to be a data-only 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 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.

Usage

The following example creates a security group and an application load balancer.

provider "aws" {}

module "networking" {
  source = "github.com/mongodb-devprod-infrastructure/terraform-aws-networking-data-only"

  vpc_name = "tutorial-vpc"
}

resource "aws_security_group" "this" {
  ingress = [
    {
      cidr_blocks = ["0.0.0.0/0"]
      from_port   = 443
      protocol    = "TCP"
      to_port     = 443
    }
  ]

  vpc_id = module.networking.vpc_id
}

resource "aws_lb" "this" {
  internal           = false
  load_balancer_type = "application"
  security_groups    = [aws_security_group.this.id]
  subnets            = module.networking.public_subnets
}

Requirements

Name Version
terraform >= 1.0
aws ~> 4

Providers

Name Version
aws ~> 4

Modules

No modules.

Resources

Name Type
aws_availability_zones.this data source
aws_subnet.this data source
aws_subnets.this data source
aws_vpc.this data source

Inputs

Name Description Type Default Required
availability_zones Select subnets only in the given AZs set(string) [] no
vpc_name The name of the VPC string n/a yes

Outputs

Name Description
dns_hostnames_enabled Indicates if instances launched in this VPC will have public DNS hostnames
dns_support_enabled Indicates if DNS support is enabled for this VPC
private_subnets List of private subnets in this VPC
public_subnets List of public subnets in this VPC
vpc_arn Arn of this VPC
vpc_cidr_block CIDR range for this VPC
vpc_cidr_blocks All CIDR ranges for this VPC
vpc_id The ID of the VPC

Contributing

Please refer to the CONTRIBUTING document for more information.

License

Apache License 2.0