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

Resource map-typed arguments various crashes #10187

Closed
moio opened this issue Nov 17, 2016 · 6 comments
Closed

Resource map-typed arguments various crashes #10187

moio opened this issue Nov 17, 2016 · 6 comments
Assignees

Comments

@moio
Copy link
Contributor

moio commented Nov 17, 2016

Terraform Version

0.8.0 dev, current master (7293630)

Affected Resource(s)

Terraform core, any resource which has an argument of type map (eg. heroku_app's config_vars).

Terraform Configuration Files

provider "heroku" {
    email = "dummy"
    api_key = "dummy"
}

variable "app_config" {
  type = "list"

  default = [
    {
      foo = "bar"
      baz = "bam"
    },
    {
      foo = "bar"
      baz = "bam"
    },
  ]
}
  
resource "heroku_app" "test" {
  name   = "test-app"
  region = "us"

  // Scenario 1
  // this works partially (number of resources is 1, should be 2, see #8867):
  #config_vars = ["${var.app_config}"]

  // this leads to terraform crash (expected type error):
  #config_vars = "${var.app_config}"

  // Scenario 2
  // this works:
  #config_vars = ["${map("foo", "bar")}"]

  // this leads to terraform crash (expected type error):
  #config_vars = "${list(map("foo", "bar"))}"
    
  // Scenario 3
  // this works (type error: should be a map):
  #config_vars = ["${map("foo", "bar")}"]
  #config_vars = ["lalala"]

  // this leads to misleading error (unknown type for string *ast.ListType):
  #config_vars = ["${map("foo", "bar")}"]
  #config_vars = "lalala"
}

Expected Behavior

See comments in scenarios above.

Actual Behavior

See comments in scenarios above.

Steps to Reproduce

  1. uncomment one or more lines according to comments above
  2. terraform plan

Important Factoids

  • I am not sure if this should be reported as 3 separate issues, or if cause is common. Please advise.
  • I have another similar bug I cannot presently reproduce with builtin providers, only with terraform-provider-libvirt. I am fairly sure it is a bug in core - should I open an issue for that too?

References

@jbardin
Copy link
Member

jbardin commented Nov 21, 2016

Hi @moio,

Thanks for the bug report! The crashes should be fixed in master now. As for the type errors, or lack there of, we may have to hold off until after 0.8 where we are planning on reworking the underlying type system which should fix nested map/list encoding ambiguities.

I removed the crash tag, and I'll leave this open pending the interpolation type issues.

@moio
Copy link
Contributor Author

moio commented Nov 22, 2016

@jbardin great, thanks so far! I tested in my setup and crashes are indeed gone! 👍

What about scenario 1, where plan is inconsistent on the number of vars? Even in latest terraform I get (emphasis mine):

  • heroku_app.test
    all_config_vars.%: ""
    config_vars.#: "2"
    config_vars.0.%: "2"
    config_vars.0.baz: "bam"
    config_vars.0.foo: "bar"
    git_url: ""

Only 1 var is populated despite config_vars.# being 2. This obviously leads to failures during apply, too.

Is there a chance this could be fixed before 0.8, through #8867 or otherwise?

@jbardin
Copy link
Member

jbardin commented Nov 22, 2016

@moio,

Let me see if I can get the first case working for 0.8. The underlying issue is rather deep, and is going to take a lot of work to solve in it's entirety, but we may be able to add another workaround here.

jbardin added a commit that referenced this issue Nov 29, 2016
Fix some cases for nested maps and lists
@jbardin
Copy link
Member

jbardin commented Nov 29, 2016

These cases are now all working as expected.

The string type error in scenario 3 is now:

config_vars: should be a list

Thanks for the thorough bug report!

@jbardin jbardin closed this as completed Nov 29, 2016
@moio
Copy link
Contributor Author

moio commented Nov 30, 2016

Thanks for taking care of all of these corner cases @jbardin! I look forward to test them all in my rather complicated setup soon! 😉

@ghost
Copy link

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

No branches or pull requests

3 participants