Terraform: Unable to pass an empty list to a module

Created on 29 Apr 2015  ยท  13Comments  ยท  Source: hashicorp/terraform

I am using a string variable combined with split() pass lists to a module. The empty string splits to an array containing an empty string, so there is no way for the user of the module to specify an empty list.

This is similar to what I am doing.

bug core

Most helpful comment

The other thing is [""] is a length of 1 while [] is a length of 0.

All 13 comments

Going to close this as a dup of #2240. I know thats newer, but there is activity there as well as work being done to fix it.

That appears to be a different issue. #2240 was about split on a string that does not contain a delimiter returning a string instead of an array.

My issue is that split on an empty string returns an one item array containing an empty string. I need a way to pass an empty list into a module.

output "length" {
        value = "${length(split(",", ""))}"
}
terraform apply

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

  length = 1

@svend I believe https://github.com/hashicorp/terraform/pull/2973 is solving that problem.

@radeksimko Thanks, I'll watch that PR.

@mitchellh, this should not be closed, since it's not a duplicate of #2240 as @svend points out.

This bug seems to have re-appeared in v0.8.5. Can it be re-opened?

Ping @mitchellh @radeksimko

@maxrothman given how old this issue is, it seems unlikely that exactly this problem has arisen again, but I don't doubt that something similar could have arisen.

Would you mind opening a new issue with some details on what you're seeing? Some up-to-date repro steps against v0.8.5 would make it more likely that someone on the Terraform team would be able to track down and fix the issue you're seeing.

I have opened a possibly relevant issue.

FWIW the resolution of the original PR was to encourage users to use the compact interpolation function, and that otherwise, this was intended behavior.

Thank you, @maxrothman!

The other thing is [""] is a length of 1 while [] is a length of 0.

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.

Was this page helpful?
0 / 5 - 0 ratings