Skip to content

Commit

Permalink
Reserve static internal ips for etcds and cfssl server instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos Filippopoulos committed Jun 8, 2018
1 parent fba0592 commit 70a411e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cfssl.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ resource "random_string" "cfssl_suffix" {
}
}

// reserve Ip address
resource "google_compute_address" "cfssl_server_address" {
name = "cfssl-server-address-${count.index}-${var.cluster_name}"
address_type = "INTERNAL"
subnetwork = "${var.subnetwork_link}"
address = "${var.cfssl_server_address}"
}

// Instance
resource "google_compute_instance" "cfssl" {
name = "cfssl-${var.cluster_name}-${random_string.cfssl_suffix.result}"
Expand All @@ -54,7 +62,7 @@ resource "google_compute_instance" "cfssl" {

network_interface {
subnetwork = "${var.subnetwork_link}"
address = "${var.cfssl_server_address}"
address = "${google_compute_address.cfssl_server_address.address}"
}

tags = ["${concat(list("cfssl-${var.cluster_name}"), var.cluster_instance_tags)}"]
Expand Down
11 changes: 10 additions & 1 deletion etcd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ resource "random_string" "r" {
}
}

// reserve Ip addresses
resource "google_compute_address" "etcd_addresses" {
count = "${var.etcd_instance_count}"
name = "etcd-address-${count.index}-${var.cluster_name}"
address_type = "INTERNAL"
subnetwork = "${var.subnetwork_link}"
address = "${var.etcd_addresses[count.index]}"
}

// Instances
resource "google_compute_instance" "etcd" {
count = "${var.etcd_instance_count}"
Expand All @@ -65,7 +74,7 @@ resource "google_compute_instance" "etcd" {

network_interface {
subnetwork = "${var.subnetwork_link}"
address = "${var.etcd_addresses[count.index]}"
address = "${google_compute_address.etcd_addresses.*.address[count.index]}"
}

tags = ["${concat(list("etcd-${var.cluster_name}"), var.cluster_instance_tags)}"]
Expand Down

0 comments on commit 70a411e

Please sign in to comment.