terraform-provider-kubernetes
terraform-provider-kubernetes copied to clipboard
Cycle dependency in Kubernetes provider when referencing to the gke module via a local variable
Introduction
Terraform detects a cycle change when creating the provider "kubernetes" when referencing to the terraform-provider-kubernetes module indirectly via a local variable.
I am illustrating below a very simple broken example and a working example to compare it with.
Terraform Version, Provider Version and Kubernetes Version
$ terraform -v
Terraform v1.11.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v6.26.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.36.0
+ provider registry.terraform.io/hashicorp/random v3.7.1
Affected Resource(s)
provider registry.terraform.io/hashicorp/kubernetes
Terraform Configuration Files
Broken example
# main.tf
# Example of a broken configuration, where `terraform validate` detects
# a cycle dependency.
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google"
version = ">= 36.0.0"
name = "broken"
ip_range_services = null
ip_range_pods = null
project_id = null
network = null
subnetwork = null
}
locals {
gke = module.gke
}
provider "kubernetes" {
host = "https://${local.gke.endpoint}"
}
Working example
The only change versus the previous example is replacing local.gke -> module.gke. This is sufficient for terraform validate to succeed.
# main.tf
# Example where `terraform validate` succeeds.
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google"
version = ">= 36.0.0"
name = "working"
ip_range_services = null
ip_range_pods = null
project_id = null
network = null
subnetwork = null
}
provider "kubernetes" {
host = "https://${module.gke.endpoint}"
}
Debug Output
https://gist.github.com/gioannidis/c541bb41c34b18a7aeb15b9498abfbd5
Steps to Reproduce
- Copy the broken example to your
main.tffile. - Execute
terraform init. - Execute
terraform validate.
Expected Behavior
terraform validate should output: Success! The configuration is valid.
Actual Behavior
Terraform detects a cycle dependency.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment