Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Fails with error if create_resources set to false #42

Closed
stuart-c opened this issue Oct 18, 2019 · 6 comments · Fixed by #43
Closed

Fails with error if create_resources set to false #42

stuart-c opened this issue Oct 18, 2019 · 6 comments · Fixed by #43
Labels
bug Something isn't working

Comments

@stuart-c
Copy link

stuart-c commented Oct 18, 2019

I'm getting the following error:

Error: Invalid index

  on .terraform/modules/k8s-namespace/main.tf line 52, in module "namespace_roles":
  52:   namespace   = kubernetes_namespace.namespace[0].id
    |----------------
    | kubernetes_namespace.namespace is empty tuple

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

The cause looks to be here:

https://github.com/gruntwork-io/terraform-kubernetes-helm/blob/master/modules/k8s-namespace/main.tf#L52

I think the fix would be to change that line to

namespace = var.create_resources ? kubernetes_namespace.namespace[0].id : ""

@yorinasub17
Copy link
Contributor

Can you share which version of terraform you are using? I am not seeing this error on 0.12.9, so it might be a behavior on older versions.

@yorinasub17
Copy link
Contributor

For reference, here is the PR that adds a test to verify this behavior (#43). Note that I didn't have to touch k8s-namespace to get the test passing.

@stuart-c
Copy link
Author

This is with Terraform 0.12.11

@yorinasub17
Copy link
Contributor

Got it. I just repro'd it.

@yorinasub17
Copy link
Contributor

Just updated the PR with the fix. Can you try to see if it works with the branch yori-address-create-resources?

@efernandes-dev-ops
Copy link

Thanks for fixing this, I can confirm it all works fine. @yorinasub17 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
3 participants