hobby-kube / provisioning

Kubernetes cluster provisioning using Terraform.
https://hobby-kube.dev/guide
MIT License
312 stars 112 forks source link

Terraform: 0.12 - count is a reserved argument name #47

Closed chris-free closed 5 years ago

chris-free commented 5 years ago
Error: Reserved argument name in module block

  on main.tf line 40, in module "swap":
  40:   count       = "${var.node_count}"

The name "count" is reserved for use in a future version of Terraform.

Error: Reserved argument name in module block

  on main.tf line 47, in module "dns":
  47:   count      = "${var.node_count}"

The name "count" is reserved for use in a future version of Terraform.

Error: Reserved argument name in module block

  on main.tf line 93, in module "wireguard":
  93:   count        = "${var.node_count}"

The name "count" is reserved for use in a future version of Terraform.
Error: Reserved argument name in module block

  on main.tf line 103, in module "firewall":
 103:   count                = "${var.node_count}"

The name "count" is reserved for use in a future version of Terraform.

Error: Reserved argument name in module block

  on main.tf line 114, in module "etcd":
 114:   count       = "${var.etcd_node_count}"

The name "count" is reserved for use in a future version of Terraform.

Error: Reserved argument name in module block

  on main.tf line 124, in module "kubernetes":
 124:   count          = "${var.node_count}"

The name "count" is reserved for use in a future version of Terraform.

If "node_count" is an acceptable name I can make a PR

pstadler commented 5 years ago

If "node_count" is an acceptable name I can make a PR

Yes it is, a PR would be great.

Related: https://github.com/hobby-kube/guide/issues/76

chris-free commented 5 years ago

Hi pstadler,

I have started doing the 0.12 upgrade change: https://github.com/chris-free/provisioning/commit/86c2404c803659ef0cbdb9c34eb946ca55f6fde6

So far:

  1. Changing the restricted keywords count/version
  2. Explictly setting block attributes e.g "var {" => "var = {"

I will continue doing some more tomorrow, I was wondering in the mean time if you could assist me on what this does:


locals {
  etcd_hostnames   = "${slice(var.hostnames, 0, var.node_count)}"
  etcd_vpn_ips     = "${slice(var.vpn_ips, 0, var.node_count)}"
}

In 'service/etcd/main.tf' now throws this error:

Error: Invalid function argument

  on service/etcd/main.tf line 20, in locals:
  20:   etcd_hostnames   = "${slice(var.hostnames, 0, var.node_count)}"
    |----------------
    | var.node_count is 3

Invalid value for "end_index" parameter: end index must not be greater than
the length of the list.

Error: Invalid function argument

  on service/etcd/main.tf line 21, in locals:
  21:   etcd_vpn_ips     = "${slice(var.vpn_ips, 0, var.node_count)}"
    |----------------
    | var.node_count is 3

Invalid value for "end_index" parameter: end index must not be greater than
the length of the list.

I couldn't find any documenation on what this is doing, is this a type conversion of some sort?

pstadler commented 5 years ago

Number of hosts running etcd is configurable and can be less than the actual k8s node count. This was probably a bug, handled nicely by Terraform < 0.12. Try node_count - 1. Thanks for your effort!

pstadler commented 5 years ago

By the way, feel free to open a WIP PR already.

pstadler commented 5 years ago

This has been fixed with https://github.com/hobby-kube/provisioning/pull/48