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

terraform destroy fails with module outputs #18661

Closed
oliviabarrick opened this issue Aug 12, 2018 · 2 comments
Closed

terraform destroy fails with module outputs #18661

oliviabarrick opened this issue Aug 12, 2018 · 2 comments

Comments

@oliviabarrick
Copy link

I am using the following terraform module called test/test.tf:

provider "digitalocean" {
  token = "...."
}

resource "digitalocean_floating_ip" "kubernetes_ip" {
  region = "tor1"
}

data "external" "kubeconfig" {
  program = ["bash", "-c", "jq -Mc '{kubeconfig:\"\"}'"]

  query = {
    api_server = "${digitalocean_floating_ip.kubernetes_ip.ip_address}"
  }

  depends_on = ["digitalocean_floating_ip.kubernetes_ip"]
}

output "kubeconfig" {
  value = "${data.external.kubeconfig.result["kubeconfig"]}"
}

And then I have test.tf:

module "kubernetes" {
  source = "./test"
}

output "kubeconfig" {
  sensitive = true
  value = "${module.kubernetes.kubeconfig}"
}

Run:

terraform init
terraform apply

It will fail on terraform destroy:

➜  ttest git:(master) ✗ terraform destroy
digitalocean_floating_ip.kubernetes_ip: Refreshing state... (ID: 174.138.114.123)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  - module.kubernetes.digitalocean_floating_ip.kubernetes_ip


Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

module.kubernetes.digitalocean_floating_ip.kubernetes_ip: Destroying... (ID: 174.138.114.123)
module.kubernetes.digitalocean_floating_ip.kubernetes_ip: Destruction complete after 0s

Error: Error applying plan:

1 error(s) occurred:

* module.kubernetes.output.kubeconfig: Resource 'data.external.kubeconfig' does not have attribute 'result' for variable 'data.external.kubeconfig.result'

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.


➜  ttest git:(master) ✗ 
@mildwonkey
Copy link
Contributor

Hi @justinbarrick -
Sorry for the long silence on this, and I'm sorry you've run across this bug. It's a known issue; the main (current) conversation is in #18026 so I am going to close this ticket in favor of that one. Please go ahead and add your 👍 to that issue.
Thanks!

@ghost
Copy link

ghost commented Apr 2, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
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

2 participants