Terraform module: vpc

From wikieduonline
Jump to navigation Jump to search

Inputs (222)[1][edit]

name
enable_nat_gateway
single_nat_gateway
enable_dns_hostnames
enable_vpn_gateway

public_subnet_tags
private_subnet_tags

Official example[edit]

module "vpc" {
 source = "terraform-aws-modules/vpc/aws"

 name = "my-vpc"
 cidr = "10.0.0.0/16"

 azs             = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
 private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
 public_subnets  = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

 enable_nat_gateway = true
 enable_vpn_gateway = true

 tags = {
   Terraform = "true"
   Environment = "dev"
 }
}

Additional examples[edit]

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.2.0"

  name                 = "education-vpc"
  cidr                 = "10.0.0.0/16"
  azs                  = data.aws_availability_zones.available.names
  private_subnets      = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  public_subnets       = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]
  enable_nat_gateway   = true
  single_nat_gateway   = true
  enable_dns_hostnames = true 

  tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
  }

  public_subnet_tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
    "kubernetes.io/role/elb"                      = "1"
  }

  private_subnet_tags = {
    "kubernetes.io/cluster/${local.cluster_name}" = "shared"
    "kubernetes.io/role/internal-elb"             = "1"
  }
}


Simple 1 zone VPC with access to RDS[edit]

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.2.0"

  name                 = "vpcsinglezone"
  cidr                 = "192.168.0.0/16"
  azs                  = eu-west-1a
  public_subnets       = ["192.168.0.0/24"]
  enable_nat_gateway   = true
  single_nat_gateway   = true
  enable_dns_hostnames = true 
  enable_dns_support   = true

  create_database_subnet_group           = true
  create_database_subnet_route_table     = true
  create_database_internet_gateway_route = true

  tags = {
    Terraform = "true"
    Environment = "dev"
  }
}

Resources: 76[edit]

aws_cloudwatch_log_group.flow_log
aws_customer_gateway.this
aws_db_subnet_group.database
aws_default_network_acl.this
aws_default_route_table.default
aws_default_security_group.this
aws_default_vpc.this
aws_egress_only_internet_gateway.this
aws_eip.nat
aws_elasticache_subnet_group.elasticache
aws_flow_log.this
aws_iam_policy.vpc_flow_log_cloudwatch
aws_iam_role.vpc_flow_log_cloudwatch
aws_iam_role_policy_attachment.vpc_flow_log_cloudwatch
aws_internet_gateway.this
aws_nat_gateway.this
aws_network_acl.database
aws_network_acl.elasticache
aws_network_acl.intra
aws_network_acl.outpost
aws_network_acl.private
aws_network_acl.public
aws_network_acl.redshift
aws_network_acl_rule.database_inbound
aws_network_acl_rule.database_outbound
aws_network_acl_rule.elasticache_inbound
aws_network_acl_rule.elasticache_outbound
aws_network_acl_rule.intra_inbound
aws_network_acl_rule.intra_outbound
aws_network_acl_rule.outpost_inbound
aws_network_acl_rule.outpost_outbound
aws_network_acl_rule.private_inbound
aws_network_acl_rule.private_outbound
aws_network_acl_rule.public_inbound
aws_network_acl_rule.public_outbound
aws_network_acl_rule.redshift_inbound
aws_network_acl_rule.redshift_outbound
aws_redshift_subnet_group.redshift
aws_route.database_internet_gateway
aws_route.database_ipv6_egress
aws_route.database_nat_gateway
aws_route.private_ipv6_egress
aws_route.private_nat_gateway
aws_route.public_internet_gateway
aws_route.public_internet_gateway_ipv6
aws_route_table.database
aws_route_table.elasticache
aws_route_table.intra
aws_route_table.private
aws_route_table.public
aws_route_table.redshift
aws_route_table_association.database
aws_route_table_association.elasticache
aws_route_table_association.intra
aws_route_table_association.outpost
aws_route_table_association.private
aws_route_table_association.public
aws_route_table_association.redshift
aws_route_table_association.redshift_public
aws_subnet.database
aws_subnet.elasticache
aws_subnet.intra
aws_subnet.outpost
aws_subnet.private
aws_subnet.public
aws_subnet.redshift
aws_vpc.this
aws_vpc_dhcp_options.this
aws_vpc_dhcp_options_association.this
aws_vpc_endpoint.this
aws_vpc_ipv4_cidr_block_association.this
aws_vpn_gateway.this
aws_vpn_gateway_attachment.this
aws_vpn_gateway_route_propagation.intra
aws_vpn_gateway_route_propagation.private
aws_vpn_gateway_route_propagation.public

Related[edit]

See also[edit]

  • https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest?tab=inputs
  • Advertising: