kinvolk / lokomotive

🪦 DISCONTINUED Further Lokomotive development has been discontinued. Lokomotive is a 100% open-source, easy to use and secure Kubernetes distribution from the volks at Kinvolk
https://kinvolk.io/lokomotive-kubernetes/
Apache License 2.0
320 stars 49 forks source link

`lokoctl cluster apply` fails using S3 backend #1016

Closed surajssd closed 4 years ago

surajssd commented 4 years ago

Other person created a cluster and shared lokocfg file with me. When I run lokoctl cluster apply -v it fails with following error:

...
module.dns.aws_route53_record.apiserver_public: Refreshing state... [id=XXXXXXXXXXXXXX_foobar-demo-foobar.net._A]

Error: Invalid index

  on ../terraform-modules/bootkube/outputs.tf line 95, in output "bootstrap-secrets_values":
  95:   value = var.enable_tls_bootstrap ? local_file.bootstrap-secrets[0].content : ""
    |----------------
    | local_file.bootstrap-secrets is empty tuple

The given key does not identify an element in this collection value.

Releasing state lock. This may take a few moments...
FATA[0042] Failed to reconcile cluster state: failed checking execution status: exit status 1  args="[]" command="lokoctl cluster apply"

The cluster is created with lokoctl version v0.4.1. And I can reproduce the error with 0.4.1 and current master.

invidian commented 4 years ago

The solution for it is to use locals to save value of local_file.bootstrap-secrets[0].content and to use local in value = instead of local_file reference.

This happens because if you remove assets directory, len(local_file.bootstrap-secrets) will be 0 after Terraform refreshes the state.