Skip to content

Commit

Permalink
Fixes for BYO VPC:
Browse files Browse the repository at this point in the history
* don't condition the creation of the VPC resource
  (hashicorp/hil#50)
* pass external subnet IDs into the VPC module
  • Loading branch information
alexsomesan committed Mar 24, 2017
1 parent 94b7c49 commit 34b10db
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
9 changes: 7 additions & 2 deletions modules/aws/vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ variable "external_vpc_id" {
}

variable "external_master_subnets" {
type = "list"
type = "list"
}

variable "external_worker_subnets" {
type = "list"
type = "list"
}

variable "dummy_vpc_name" {
type = "string"
default = "terraform-side-effect"
}
1 change: 1 addition & 0 deletions modules/aws/vpc/vpc-public.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ resource "aws_route_table" "default" {
}

resource "aws_main_route_table_association" "main_vpc_routes" {
count = "${var.external_vpc_id == "" ? 1 : 0}"
vpc_id = "${data.aws_vpc.cluster_vpc.id}"
route_table_id = "${aws_route_table.default.id}"
}
Expand Down
13 changes: 10 additions & 3 deletions modules/aws/vpc/vpc.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
data "aws_availability_zones" "azs" {}

resource "aws_vpc" "new_vpc" {
count = "${length(var.external_vpc_id) > 0 ? 0 : 1}"
cidr_block = "${var.cidr_block}"
# count = "${length(var.external_vpc_id) > 0 ? 0 : 1}"
#
# We can't yet use the count gate here because of terraform issues:
# https://github.com/hashicorp/hil/issues/50
# https://github.com/hashicorp/terraform/issues/11566
# This should be re-enabled when above issues are fixed.
#
cidr_block = "${var.cidr_block}"

enable_dns_hostnames = true
enable_dns_support = true

tags {
Name = "${var.cluster_name}"
Name = "${var.external_vpc_id == "" ? var.cluster_name : "${var.cluster_name}-${var.dummy_vpc_name}"}"
KubernetesCluster = "${var.cluster_name}"
}
}
Expand Down
8 changes: 4 additions & 4 deletions platforms/aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
data "aws_availability_zones" "azs" {}

module "vpc" {
source = "../../modules/aws/vpc"
source = "../../modules/aws/vpc"

az_count = "${var.tectonic_aws_az_count}"
cidr_block = "${var.tectonic_aws_vpc_cidr_block}"
cluster_name = "${var.tectonic_cluster_name}"

external_vpc_id = "${var.tectonic_aws_external_vpc_id}"
external_master_subnets = []
external_worker_subnets = []
external_master_subnets = ["${compact(var.tectonic_aws_external_master_subnets)}"]
external_worker_subnets = ["${compact(var.tectonic_aws_external_worker_subnets)}"]
}

module "etcd" {
Expand Down Expand Up @@ -89,4 +89,4 @@ module "workers" {
ssh_key = "${var.tectonic_aws_ssh_key}"
cl_channel = "${var.tectonic_cl_channel}"
user_data = "${module.ignition-workers.ignition}"
}
}
12 changes: 11 additions & 1 deletion platforms/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ variable "tectonic_aws_az_count" {

variable "tectonic_aws_external_vpc_id" {
type = "string"
}
}

variable "tectonic_aws_external_master_subnets" {
type = "list"
default = [""]
}

variable "tectonic_aws_external_worker_subnets" {
type = "list"
default = [""]
}

0 comments on commit 34b10db

Please sign in to comment.