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

Indexing of computed lists does not work #8695

Closed
jszwedko opened this issue Sep 6, 2016 · 3 comments · Fixed by #10657
Closed

Indexing of computed lists does not work #8695

jszwedko opened this issue Sep 6, 2016 · 3 comments · Fixed by #10657
Assignees

Comments

@jszwedko
Copy link
Contributor

jszwedko commented Sep 6, 2016

Terraform Version

Terraform v0.7.3

Affected Resource(s)

n/a -- interpolation issue.

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

resource "aws_network_interface" "foo" {
  count = "3"
  subnet_id = "SUBNET ID"
}

resource "aws_route53_record" "aws_dns" {
  name = "test.com"
  count = 3

  zone_id = "ZONE ID"
  type = "CNAME"
  ttl = 30
  records = ["${aws_network_interface.foo.*.private_ips[count.index]}"]
}

Debug Output

https://gist.github.com/jszwedko/db8a5b43a61e7139fef6a195e1c588cb

Expected Behavior

A route53 record is created using the private IPs from the created network interfaces.

Actual Behavior

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.


Error running plan: 3 error(s) occurred:

* At column 3, line 1: invalid index operation into non-indexable type: TypeString in:

${aws_network_interface.foo.*.private_ips[count.index]}
* At column 3, line 1: invalid index operation into non-indexable type: TypeString in:

${aws_network_interface.foo.*.private_ips[count.index]}
* At column 3, line 1: invalid index operation into non-indexable type: TypeString in:

${aws_network_interface.foo.*.private_ips[count.index]}

Steps to Reproduce

  1. terraform plan

Important Factoids

If you comment out the aws_route53_record, terraform plan and terraform apply you can than uncomment it and it creates correctly (now that the value it is indexing is no longer computed).

References

#7906 is a related issue

mitchellh added a commit that referenced this issue Dec 11, 2016
Fixes #8695

When a list count was computed in a multi-resource access
(foo.bar.*.list), we were returning the value as empty string. I don't
actually know the histocal reasoning for this but this can't be correct:
we must return unknown.

When changing this to unknown, the new tests passed and none of the old
tests failed. This leads me further to believe that the return empty
string is probably a holdover from long ago to just avoid crashes or
UUIDs in the plan output and not actually the correct behavior.
@mitchellh mitchellh self-assigned this Dec 11, 2016
@mitchellh
Copy link
Contributor

Have a fix queued in the referenced PR!

@jszwedko
Copy link
Contributor Author

Awesome!

@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants