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

Cannot index into a list returned by a function in interpolation expressions #9850

Closed
wr0ngway opened this issue Nov 3, 2016 · 4 comments
Closed
Milestone

Comments

@wr0ngway
Copy link

wr0ngway commented Nov 3, 2016

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.7.8

Affected Resource(s)

  • core

Terraform Configuration Files

variable "small_list" {
  type = "list"
  default = [{x = "y"}]
}

variable "filler_list" {
  type = "list"
  default = [{}, {}, {}, {}]
}

output "out2" {
  value = "${concat(var.small_list, var.filler_list)[0]}"
  // also fails
  // value = "${list("1", "2")[0]}"
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

I should be able to get an item from a dynamically generated list

Actual Behavior

Error loading Terraform: Error loading config: Error loading /Users/mconway/workspace/terraform-test/lists/main.tf: Error reading config for output out2: parse error: syntax error

Steps to Reproduce

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

  1. terraform apply

Important Factoids

Nope, pretty simple example

References

N/A

@apparentlymart
Copy link
Contributor

This is one of the things #11704 aimed to address. Although that wasn't able to land in its current state it is still something I plan to address in future, though likely to be considered as part of a more holistic plan to fix some wrinkles in the design of Terraform's interpolation language.

@apparentlymart apparentlymart changed the title Cannot index into a dynamic list Cannot index into a list returned by a function in interpolation expressions Apr 5, 2017
@apparentlymart apparentlymart added config and removed core labels Nov 7, 2018
@apparentlymart apparentlymart added this to the v0.12.0 milestone Nov 7, 2018
@apparentlymart
Copy link
Contributor

Hi again @wr0ngway!

That "holistic plan" I mentioned has now resulted in a new implementation of the configuration language in master, ready to be included in the forthcoming v0.12.0 release.

I tested the configuration you gave with the v0.12.0-alpha2 prerelease build, and it seems to indeed be working as expected:

$ terraform apply

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

Outputs:

out2 = {}

Thanks for reporting this, and sorry for not keeping this issue updated.

@wr0ngway
Copy link
Author

wr0ngway commented Nov 7, 2018

Cool, thanks!

@ghost
Copy link

ghost commented Mar 31, 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 Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants