Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using cluster_id output in other modules/actions #275

Closed
1 of 4 tasks
fubar opened this issue Feb 11, 2019 · 4 comments
Closed
1 of 4 tasks

Error when using cluster_id output in other modules/actions #275

fubar opened this issue Feb 11, 2019 · 4 comments

Comments

@fubar
Copy link

fubar commented Feb 11, 2019

I have issues

using the cluster_id output in other modules/actions

I'm submitting a...

  • bug report
  • feature request
  • support request
  • kudos, thank you, warm fuzzy

What is the current behavior?

Consider this test.sh bash script:

#!/bin/bash
echo "{\"kubeconfig\":\"${1}\"}"

And these Terraform definitions:

locals {
  eks_cluster_name = "foo-cluster"
}

module "foo-cluster" {
  cluster_name = "${local.eks_cluster_name}"
  // ...
}

data "external" "kube_config_test" {
  program = [
    "test.sh",
    "${module.foo-cluster.cluster_id}"
  ]
}

This results in this error:

Resource 'data.external.kube_config_test' does not have attribute 'result.kubeconfig' for variable 'data.external.kube_config_test.result.kubeconfig'

However, if I reference the local variable, it works fine:

data "external" "kube_config_test" {
  program = [
    "test.sh",
    "${local.eks_cluster_name}"
  ]
}

The script works fine; I've validated its output and it returns the expected string {"kubeconfig":"foo-cluster"} in both scenarios, but for some reason Terraform throws an error when using module.foo-cluster.cluster_id.

What's failing here?

Environment details

Mac OS 10.13

Terraform and module versions:

* provider.aws: version = "~> 1.57"
* provider.external: version = "~> 1.0"
* provider.kubernetes: version = "~> 1.5"
* provider.local: version = "~> 1.1"
* provider.null: version = "~> 2.0"
* provider.random: version = "~> 2.0"
* provider.template: version = "~> 2.0"
@fubar
Copy link
Author

fubar commented Feb 11, 2019

Another example of this issue:

provider "kubernetes" {
  config_path = "${path.cwd}/kubeconfig_${module.foo-cluster.cluster_id}"
}

Throws:

module.foo.provider.kubernetes: Failed to load config (; default context): invalid configuration: no configuration has been provided

However, this works fine:

provider "kubernetes" {
  config_path = "${path.cwd}/kubeconfig_${local.eks_cluster_name}"
}

@skang0601
Copy link
Contributor

I don't think the issue is with this module itself but rather the provider or terraform. This issue seems relevant: hashicorp/terraform-provider-kubernetes#142

@max-rocket-internet
Copy link
Contributor

Closing after no update in a long time. Feel free to reopen 🙂

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants