Skip to content

Commit dd662d9

Browse files
committed
swap vpc
1 parent 797e5ff commit dd662d9

3 files changed

Lines changed: 23 additions & 27 deletions

File tree

terraform/main.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
provider "aws" {
22
region = var.region
3-
default_tags { tags = var.default_tags }
3+
default_tags { tags = var.tags }
4+
}
5+
6+
data "aws_availability_zones" "available" {
7+
state = "available"
8+
9+
# https://docs.aws.amazon.com/eks/latest/userguide/network-reqs.html#cluster-subnets
10+
exclude_zone_ids = ["use1-az3", "usw1-az2", "cac1-az3"]
411
}
512

613
locals {
7-
cluster_prefix = "${var.cluster_name}-${var.environment}"
14+
cluster_prefix = "hotosm-${var.environment}"
15+
16+
azs = slice(sort(data.aws_availability_zones.available.names), 0, min(4, length(data.aws_availability_zones.available.names)))
17+
vpc_cidr = "10.0.0.0/16"
818
}

terraform/network.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# TODO: swap out to no longer use module
21
module "vpc" {
3-
source = "git::https://github.com/hotosm/terraform-aws-vpc/"
2+
source = "terraform-aws-modules/vpc/aws"
3+
version = "~> 5.0"
44

5-
deployment_environment = var.environment
5+
name = "k8s-infra-${var.environment}"
6+
cidr = local.vpc_cidr
7+
enable_nat_gateway = true
8+
single_nat_gateway = true
69

7-
default_tags = var.default_tags
8-
project_meta = var.project_meta
10+
azs = local.azs
11+
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)]
12+
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 48)]
913
}

terraform/variables.tf

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,18 @@ variable "region" {
1313
EOT
1414
}
1515

16-
variable "default_tags" {
16+
variable "tags" {
1717
type = map(string)
1818
default = {}
1919
description = <<-EOT
2020
(Optional) AWS resource tags.
2121
EOT
2222
}
2323

24-
variable "cluster_name" {
25-
type = string
26-
description = <<-EOT
27-
Name of EKS cluster to create
28-
EOT
29-
}
30-
3124
variable "permissions_boundary" {
3225
type = string
3326
default = null
27+
sensitive = true
3428
description = <<-EOT
3529
(Optional) ARN of the policy that is used to set the permissions boundary for
3630
the role.
@@ -164,16 +158,4 @@ variable "map_users" {
164158
description = <<-EOT
165159
(Optional) Users to include on aws-auth ConfigMap
166160
EOT
167-
}
168-
169-
variable "project_meta" {
170-
description = "Metadata required for VPC module"
171-
type = map(string)
172-
173-
default = {
174-
name = "k8s-infra"
175-
short_name = "k8s-infra"
176-
version = "0.0.1"
177-
url = "https://github.com/hotosm/k8s-infra"
178-
}
179161
}

0 commit comments

Comments
 (0)