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

Panic on apply after destroy #12183

Closed
sethvargo opened this issue Feb 22, 2017 · 3 comments · Fixed by #12210
Closed

Panic on apply after destroy #12183

sethvargo opened this issue Feb 22, 2017 · 3 comments · Fixed by #12210

Comments

@sethvargo
Copy link
Contributor

sethvargo commented Feb 22, 2017

Hi there,

Terraform Version

Terraform v0.9.0-dev (9ae0e077f1a43956077f8e0ac7f706f1fb5f3edc)

Affected Resource(s)

  • core

Panic Output

https://gist.github.com/sethvargo/9ca97d49f4e754607906bf63db54446b

Expected Behavior

Terraform should not have crashed.

Actual Behavior

Terraform crashed.

Steps to Reproduce

  1. Create resources
  2. Destroy resources
  3. Run apply

Steps to Fix

  1. Delete local statefile

Important Factoids

  • Using Azure, got an error on destroy, but subsequent destroy succeeded.
@sethvargo
Copy link
Contributor Author

I've narrowed down the issue. In my configs, I'm grabbing the value of a nested attribute (which is a list of maps):

frontend_ip_configuration_name = "${lookup(azurerm_lb.demo.frontend_ip_configuration[0], "name")}"

Where that is defined as

resource "azurerm_lb" "demo" {
  name                = "demo"
  location            = "${var.azurerm_location}"
  resource_group_name = "${azurerm_resource_group.demo.name}"

  frontend_ip_configuration {
    name                          = "default"
    public_ip_address_id          = "${azurerm_public_ip.demo.id}"
    private_ip_address_allocation = "dynamic"
  }
}

It looks like the graph isn't correctly setting up that dependency.

@mitchellh
Copy link
Contributor

On first look, it appears the graph is being setup properly. This looks like something else. I'm not 100% sure yet but your lookup is weird. I'm not saying you're doing something wrong, but its a usage style that I haven't seen often and I'm not sure how that plays well with computed maps.

Do you have a consistent reproduction?

I can play with this tomorrow.

mitchellh added a commit that referenced this issue Feb 23, 2017
Fixes #12183

The fix is in flatmap for this but the entire issue is a bit more
complex. Given a schema with a computed set, if you reference it like
this:

    lookup(attr[0], "field")

And "attr" contains a computed set within it, it would panic even though
"field" is available. There were a couple avenues I could've taken to
fix this:

1.) Any complex value containing any unknown value at any point is
entirely unknown.

2.) Only the specific part of the complex value is unknown.

I took route 2 so that the above works without any computed (since
"name" is not computed but something else is). This may actually have an
effect on other parts of Terraform configs, however those similar
configs would've simply crashed previously so it shouldn't break any
pre-existing configs.
@ghost
Copy link

ghost commented Apr 16, 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 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants