Created
December 2, 2020 16:31
-
-
Save redeux/3358be9bc4e541d2668e19759ff960ef to your computer and use it in GitHub Desktop.
Terraform Progressive Apply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
kubeconfig_file = "${path.module}/kubeconfig" | |
} | |
provider "local" {} | |
# provider "kubernetes" { | |
# config_path = local.kubeconfig_file | |
# } | |
provider "kubernetes" { | |
config_path = local_file.kubeconfig.filename | |
} | |
resource "local_file" "kubeconfig" { | |
depends_on = [local_file.otherstuff] | |
filename = "${path.module}/kubeconfig" | |
content = file("~/.kube/config") | |
} | |
resource "local_file" "otherstuff" { | |
count = 10 | |
filename = "${path.module}/otherstuff.${count.index}" | |
content = file("~/.kube/config") | |
} | |
resource "kubernetes_config_map" "test" { | |
depends_on = [local_file.kubeconfig] | |
metadata { | |
name = "test" | |
} | |
data = { | |
"foo" = "bar" | |
} | |
} | |
output "locals_kubeconfig_file" { | |
value = local.kubeconfig_file | |
} | |
output "local_file_kubeconfig" { | |
value = local_file.kubeconfig.filename | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
terraform-progressive-apply
This config seems to tigger the "progressive apply" issue in Terraform. Run as is, the configuration should apply without issue. However, if you swap the Kubernetes provider blocks, it should fail the first time and work the second.
Note: Assumes you have a Kubernetes cluster, such as Kind, available to you.