|
# |
|
# VPC Resources |
|
# * VPC |
|
# * Subnets |
|
# * Internet Gateway |
|
# * Route Tables |
|
# * Sec Groups |
|
|
|
module "vpc" { |
|
source = "terraform-aws-modules/vpc/aws" |
|
|
|
name = "${var.environment}-vpc" |
|
cidr = var.cidr |
|
|
|
azs = var.azs |
|
private_subnets = var.private_subnets |
|
public_subnets = var.public_subnets |
|
|
|
enable_nat_gateway = true |
|
single_nat_gateway = true |
|
one_nat_gateway_per_az = false |
|
|
|
private_subnet_tags = { |
|
"kubernetes.io/role/internal-elb" = 1 |
|
} |
|
|
|
public_subnet_tags = { |
|
"kubernetes.io/role/elb" = 1 |
|
} |
|
|
|
tags = { |
|
Environment = var.environment |
|
Application = "network" |
|
"kubernetes.io/cluster/${var.cluster_name}" = "shared" |
|
} |
|
} |
|
|
|
// variables.tf |
|
|
|
variable "environment" { |
|
type = string |
|
default = "krypton" |
|
description = "Name prefix" |
|
} |
|
|
|
variable "cidr" { |
|
type = string |
|
default = "10.0.0.0/16" |
|
description = "vpc cidr" |
|
} |
|
|
|
variable "azs" { |
|
type = list |
|
description = "Avaibility zones list" |
|
} |
|
|
|
variable "private_subnets" { |
|
type = list |
|
description = "list of private subnets in the vpc" |
|
} |
|
|
|
variable "public_subnets" { |
|
type = list |
|
description = "public subnets list" |
|
} |
|
|
|
variable "ingress_ips" { |
|
type = list |
|
description = "List of Ingress IPs" |
|
} |
|
variable "cluster_name" { |
|
type = string |
|
description = "FQDN cluster name" |
|
} |
|
|
|
// outputs.tf |
|
|
|
output "vpc_id" { |
|
value = module.vpc.vpc_id |
|
} |
|
|
|
output "vpc_cidr_block" { |
|
value = module.vpc.vpc_cidr_block |
|
} |
|
|
|
output "public_subnet_ids" { |
|
value = module.vpc.public_subnets |
|
} |
|
|
|
output "public_route_table_ids" { |
|
value = module.vpc.public_route_table_ids |
|
} |
|
|
|
output "private_subnet_ids" { |
|
value = module.vpc.private_subnets |
|
} |
|
|
|
output "private_route_table_ids" { |
|
value = module.vpc.private_route_table_ids |
|
} |
|
|
|
output "default_security_group_id" { |
|
value = module.vpc.default_security_group_id |
|
} |
|
|
|
output "nat_gateway_ids" { |
|
value = module.vpc.natgw_ids |
|
} |