Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
bootkube: feed output using local rather than local_file content
Browse files Browse the repository at this point in the history
Currently, if one has TLS bootstrap enabled and remove it's assets
directory, assuming that they use remote Terraform backend, Terraform
won't be able to evalue this output, as after refreshing,
local_file.bootstrap-secrets will be gone, as the file has been removed.

This commit moves content rendering to local variable, so module output
does not depend on local file.

Closes #1016

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Sep 28, 2020
1 parent 3008e5a commit fff55e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
16 changes: 10 additions & 6 deletions assets/terraform-modules/bootkube/assets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ resource "local_file" "kubernetes" {
})
}

# Populate bootstrap-secrets chart values file named bootstrap-secrets.yaml.
resource "local_file" "bootstrap-secrets" {
count = var.enable_tls_bootstrap == true ? 1 : 0

filename = "${var.asset_dir}/charts/kube-system/bootstrap-secrets.yaml"
content = templatefile("${path.module}/resources/charts/bootstrap-secrets.yaml", {
locals {
bootstrap_secrets = templatefile("${path.module}/resources/charts/bootstrap-secrets.yaml", {
bootstrap_tokens = [
for token in var.bootstrap_tokens :
{
Expand All @@ -101,6 +97,14 @@ resource "local_file" "bootstrap-secrets" {
})
}

# Populate bootstrap-secrets chart values file named bootstrap-secrets.yaml.
resource "local_file" "bootstrap-secrets" {
count = var.enable_tls_bootstrap == true ? 1 : 0

filename = "${var.asset_dir}/charts/kube-system/bootstrap-secrets.yaml"
content = local.bootstrap_secrets
}

locals {
kubelet = var.disable_self_hosted_kubelet == false ? 1 : 0
}
Expand Down
2 changes: 1 addition & 1 deletion assets/terraform-modules/bootkube/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ output "lokomotive_values" {
}

output "bootstrap-secrets_values" {
value = var.enable_tls_bootstrap ? local_file.bootstrap-secrets[0].content : ""
value = var.enable_tls_bootstrap ? local.bootstrap_secrets : ""
}
Loading

0 comments on commit fff55e9

Please sign in to comment.