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 count can't reference resource variable: <splat resource> #10799

Closed
mengesb opened this issue Dec 16, 2016 · 2 comments
Closed

resource count can't reference resource variable: <splat resource> #10799

mengesb opened this issue Dec 16, 2016 · 2 comments

Comments

@mengesb
Copy link
Contributor

mengesb commented Dec 16, 2016

It seems reasonable that I could do "${length(aws_eip.<name>.*.id)}" to return the count of elastic IP resources. This produces an error currently. I can successfully use this interpolation for outputs, but I cannot use it for other resource interpolations.

Further testing actually shows i might not be able to perform a length() operation on any splat... which is awful. Pretty darn sure this worked in 0.7.x series

Terraform Version

0.8.1

Affected Resource(s)

  • aws_*
  • count meta-variable?
  • length() interpolation ?

Terraform Configuration Files

resource "aws_eip" "nat-eips" {
  count = "3"
  vpc = true
}
resource "aws_instance" "instances" {
  count = "${length(aws_eip.nat-eips.*.id)}"
}

Debug Output

2016/12/16 10:47:42 [INFO] Terraform version: 0.8.1
2016/12/16 10:47:42 [INFO] CLI args: []string{"/usr/local/Cellar/terraform/0.8.1/bin/terraform", "plan"}
2016/12/16 10:47:42 [DEBUG] Detected home directory from env var: /Users/user
2016/12/16 10:47:42 [DEBUG] Detected home directory from env var: /Users/user
2016/12/16 10:47:42 [DEBUG] Attempting to open CLI config file: /Users/user/.terraformrc
2016/12/16 10:47:42 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/12/16 10:47:42 [DEBUG] Detected home directory from env var: /Users/user
module root: 1 error(s) occurred:

2016/12/16 10:47:42 [DEBUG] plugin: waiting for all plugin processes to complete...
* aws_instance.instance: resource count can't reference resource variable: aws_eip.chef-nat-eip.*.id

Panic Output

N/A

Expected Behavior

I should be able to use length() interpolation on the aws_eip resource in other count metavars of resources

Actual Behavior

terraform plan and terraform apply fails to run with the error:

* aws_instance.instance: resource count can't reference resource variable: aws_eip.chef-nat-eip.*.id

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

Important Factoids

N/A

References

@mengesb mengesb changed the title resource count can't reference resource variable: aws_eip.chef-nat-eip.*.id resource count can't reference resource variable: <splat resource> Dec 16, 2016
@mitchellh
Copy link
Contributor

Sorry, but this doesn't work and hasn't ever worked in recent memory. I tried versions 0.8.1, 0.7.13, 0.7.0, and 0.6.0 (whew!). The error message has gotten better over time, but the functionality has never worked.

There is a mega issue here at #3888 that we're hoping we can resolve with 0.9. I'll close as a dup of that.

@ghost
Copy link

ghost commented Apr 18, 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 18, 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