I'm running a private GKE cluster and want to add a NAT Gateway so I can create firewall rules from requests coming from the cluster (by default, the public IP's for all nodes are ephemeral, thus hard to keep track of).
I'm trying to follow the instructions described here, and here (to create a highly available NAT, a variation of the first link).
I'm able to install terraform
, create terraform.tfvars
on my working directory and run terraform init
. When I run terraform plan
, I receive a lot of errors like:
Error: Unsupported attribute
on ../../main.tf line 51, in module "nat-gateway":
51: module_enabled = "${var.module_enabled}"
An attribute named "module_enabled" is not expected here.
Error: Unsupported attribute
on ../../main.tf line 52, in module "nat-gateway":
52: project = "${var.project}"
An attribute named "project" is not expected here.
Error: Unsupported attribute
on ../../main.tf line 53, in module "nat-gateway":
53: region = "${var.region}"
An attribute named "region" is not expected here.
Error: Unsupported attribute
on ../../main.tf line 54, in module "nat-gateway":
54: zone = "${local.zone}"
An attribute named "zone" is not expected here.
...
I get an error for almost every input in this module (this is what ../../main.tf
points to).
module "nat-gateway" {
source = "GoogleCloudPlatform/managed-instance-group/google"
version = "1.1.14"
module_enabled = "${var.module_enabled}"
project = "${var.project}"
region = "${var.region}"
zone = "${local.zone}"
network = "${var.network}"
subnetwork = "${var.subnetwork}"
target_tags = ["${local.instance_tags}"]
instance_labels = "${var.instance_labels}"
service_account_email = "${var.service_account_email}"
machine_type = "${var.machine_type}"
name = "${local.name}"
compute_image = "${var.compute_image}"
size = 1
network_ip = "${var.ip}"
can_ip_forward = "true"
service_port = "80"
service_port_name = "http"
startup_script = "${data.template_file.nat-startup-script.rendered}"
wait_for_instances = true
metadata = "${var.metadata}"
ssh_fw_rule = "${var.ssh_fw_rule}"
ssh_source_ranges = "${var.ssh_source_ranges}"
http_health_check = "${var.autohealing_enabled}"
update_strategy = "ROLLING_UPDATE"
rolling_update_policy = [
{
type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_fixed = 0
max_unavailable_fixed = 1
min_ready_sec = 30
},
]
access_config = [
{
nat_ip = "${element(concat(google_compute_address.default.*.address, data.google_compute_address.default.*.address, list("")), 0)}"
},
]
}
I also noticed that the errors I get are the fields that are declared here but not here, so it looks like some kind of version miss-match.
I tried to change this line as follows, to get the latest from github instead of terraform registry, but that did't solve the issue.
// before:
module "nat-gateway" {
source = "GoogleCloudPlatform/managed-instance-group/google"
version = "1.1.14"
// after:
module "nat-gateway" {
source = "github.com/GoogleCloudPlatform/terraform-google-managed-instance-group"
My working directory is examples/gke-ha-nat-gateway/
, in case that matters. The whole environment is the same as freshly cloned from github, with the exception of terraform.tfvars
.
Unfortunately I'm don't have any experience with Terraform, so I don't really know how to debug this errors.
Thank you for your help!