coreos / terraform-aws-kubernetes

Install a Kubernetes cluster the CoreOS Tectonic Way: HA, self-hosted, RBAC, etcd Operator, and more
Apache License 2.0
117 stars 67 forks source link

module kubernetes.root: module container_linux: required variable "version" not set #10

Closed sunshinekitty closed 6 years ago

sunshinekitty commented 6 years ago

Using what's in examples/kubernetes.tf by itself I'm unable to terraform init with the following error:

$ terraform init     
Initializing modules...
- module.kubernetes
- module.kubernetes.container_linux
- module.kubernetes.vpc
- module.kubernetes.etcd
- module.kubernetes.ignition_masters
- module.kubernetes.masters
- module.kubernetes.ignition_workers
- module.kubernetes.workers
- module.kubernetes.kube_certs
- module.kubernetes.etcd_certs
- module.kubernetes.ingress_certs
- module.kubernetes.identity_certs
- module.kubernetes.bootkube
- module.kubernetes.tectonic
- module.kubernetes.flannel_vxlan
- module.kubernetes.calico
- module.kubernetes.canal
Error getting plugins: module root: 
  module kubernetes.root: module container_linux: required variable "version" not set

$ terraform --version
Terraform v0.11.0
jonaskint commented 6 years ago

Currently having the same issue with terraform 0.11.0 and the 1.7.9-tectonic.2 release.

jcrowthe commented 6 years ago

Same issue here too. Any updates?

PaulDuffels commented 6 years ago

Having the same issue here :( Error getting plugins: module root: module container_linux: required variable "version" not set

squat commented 6 years ago

Hi @sunshinekitty I tried reproducing this locally and found some very strange results that lead me to suspect there are some internal Terraform issues. Can you please go to your main infrastructure directory, where you ran terraform init and run: for d in .terraform/modules/*; do git --git-dir="$d"/.git describe --tags; done and please post the result.

Edit: After some more investigation, it looks like this issue is the result of new features that have been introduced in the new Terraform minor version 0.11.0. This version contains improved module support, with real support for pinning module versions using the version directive, e.g.:

module "foo" {
  source = "bar"
  version = "baz"
}

Unfortunately, this directive clashes with a variable in the container_linux module by the same name; Terraform is unable to handle variables and directives with the same name in a given module block, so the version variable is never passed to the module.

The current workaround requires the following steps:

  1. install Terraform 0.10.x
  2. change the source of the module to be a Git repository with a ref explicitly specifying the version rather than a Terraform module registry module, e.g.
    source = "github.com/coreos/terraform-aws-kubernetes?ref=1.7.9-tectonic.2"

    This is needed because Terraform <0.11.x does not support specifying module versions, which is also why the version variable will be correctly passed.

The next release will include a correct patch for this issue to fully support Terraform 0.11.x, which simply means the variable name has to be changed from version to something else.