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

Call to function "zipmap" failed: number of keys (2) does not match number of values (3). #13

Closed
Jeanno opened this issue Sep 24, 2019 · 9 comments · Fixed by #23
Closed
Labels
bug Something isn't working triaged Scoped and ready for work

Comments

@Jeanno
Copy link

Jeanno commented Sep 24, 2019

Summary

Run into the following issue when terraform apply after removing an item from the var.names list

Error: Error in function call
  on ../../terraform-google-cloud-storage/outputs.tf line 39, in output "names":
  39:   value       = zipmap(var.names, google_storage_bucket.buckets[*].name)
    |----------------
    | google_storage_bucket.buckets is tuple with 3 elements
    | var.names is list of string with 2 elements
Call to function "zipmap" failed: number of keys (2) does not match number of
values (3).
Error: Error in function call
  on ../../terraform-google-cloud-storage/outputs.tf line 44, in output "urls":
  44:   value       = zipmap(var.names, google_storage_bucket.buckets[*].url)
    |----------------
    | google_storage_bucket.buckets is tuple with 3 elements
    | var.names is list of string with 2 elements
Call to function "zipmap" failed: number of keys (2) does not match number of
values (3).

Steps to reproduce

  1. Use the module with some bucket names (e.g. names = ["first", "second", "third"])
  2. terraform apply
  3. Remove one name from the list (e.g. names = ["first", "second"])
  4. terraform apply again
  5. Encounter the above error
@Jeanno Jeanno added the bug Something isn't working label Sep 24, 2019
@ludoo
Copy link
Contributor

ludoo commented Sep 24, 2019

Yup, it's a know issue, workaround is to temporarily comment out the outputs until the new resource is in. Will probably be fixed in a future release, once we switch to using foreach instead of count.

@Jeanno
Copy link
Author

Jeanno commented Sep 24, 2019

So the list ordering issue is also known? The one that if you remove one of the names, the subsequence buckets will be replaced.

@ludoo
Copy link
Contributor

ludoo commented Sep 24, 2019

Absolutely, that's a Terraform limitation using count with resources, and will go away once we switch to foreach.

@Jeanno
Copy link
Author

Jeanno commented Sep 24, 2019

Any ongoing effort with the change? If not, I might be able to contribute to this.

@ludoo
Copy link
Contributor

ludoo commented Sep 24, 2019

We did not start yet, as the plan was to do complete 0.12 migration for all the mutiple-resource modules, then switch them all to foreach. Migration is done, we just need to find the time to tackle this. If you feel like starting, by all means that is more than welcome. :)

@morgante
Copy link
Contributor

FYI I'm not sure this is directly related to foreach vs. count. It might fix it though.

@Jberlinsky
Copy link
Contributor

Just to provide some additional context, this bug has the potential to be quite severe, requiring modifications to Terraform state and manual deletion of buckets it creates to enable Terraform Plans to run in a previously functional configuration.

@morgante
Copy link
Contributor

It shouldn't require manual deletion. There's a simple fix anyways.

@morgante morgante added the triaged Scoped and ready for work label Nov 19, 2019
@morgante
Copy link
Contributor

@Jberlinsky The fix is trivial, take a look at #23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Scoped and ready for work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants