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

Unable to access list of "list of computed values" before terraform has run. #3679

Closed
josh-padnick opened this issue Oct 29, 2015 · 5 comments

Comments

@josh-padnick
Copy link

I believe this is a bug in #2157. Given:

resource "aws_network_interface" "zk_eni_pool" {
  count = 3
  subnet_id = "subnet-123"
  security_groups = ["sg-123"]
}

I try the following:

resource "template_file" "mesos-environment" {
    filename = "${path.module}/files/user-data/mesos-environment.template"
    vars {
        eni_ip = "${join(",", aws_network_interface.zk_eni_pool.*.private_ips)}"
    }
}

This works fine once I've already done an initial terraform apply. But if I attempt to terraform apply for the first time, I receive the error:

Resource 'aws_network_interface.zk_eni_pool' does not have attribute 'private_ips' for variable 'aws_network_interface.zk_eni_pool.*.private_ips'

Replacing aws_network_interface.zk_eni_pool.*.private_ips with the following both work fine:

  • aws_network_interface.zk_eni_pool.0.private_ips, or
  • aws_network_interface.zk_eni_pool.0.subnet_id

Therefore, I interpret the root problem is that Terraform has a bug where it cannot access a list of "list of computed values". Thanks for your input.

@bryanstephens
Copy link

+1, now that #2157 fixed our issue with grabbing lists of private ips from ENIs this issue has been a pain for us with initializing our cluster for the first time as well.

@koendc
Copy link

koendc commented Dec 4, 2015

The referenced commit fixes the issue in my case. Really not sure what is the impact of this on other parts of terraform though...

@phinze
Copy link
Contributor

phinze commented Apr 18, 2016

Hi folks!

The core of this issue is that the splat operator only has defined behavior for collecting lists of resources that were created using the count meta-parameter. The fact that it sometimes works to collect set elements is an incidental side effect of it's current implementation.

We'd definitely like to get the splat operator to fully support structured attributes, but today it does not, which is why you're getting the weird behavior described here.

Just reviewed our splat operator documentation and it looks pretty thin - I will bolster that in a PR linked back here.

@mitchellh
Copy link
Contributor

Agreed this is fixed in my tests!

@ghost
Copy link

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

6 participants