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

Support count.index references in blocks w/ count #860

Closed
6 tasks
Tracked by #495
radeksimko opened this issue Apr 7, 2022 · 1 comment · Fixed by hashicorp/hcl-lang#134
Closed
6 tasks
Tracked by #495

Support count.index references in blocks w/ count #860

radeksimko opened this issue Apr 7, 2022 · 1 comment · Fixed by hashicorp/hcl-lang#134
Assignees
Milestone

Comments

@radeksimko
Copy link
Member

radeksimko commented Apr 7, 2022

Notes

#583 is not a dependency, but count.index is quite frequently used as string in various names/tags and so is important in the context of this issue.

Background

Terraform supports count.index reference within resource, data and module block and anywhere where count meta-argument is supported, for example

resource "aws_instance" "server" {
  count = 4 # create four similar EC2 instances

  ami           = "ami-a1b2c3d4"
  instance_type = "t2.micro"

  tags = {
    Name = "Server ${count.index}"
  }
}

https://www.terraform.io/language/expressions/references#block-local-values
https://www.terraform.io/language/meta-arguments/count

We don't provide any kind of support for this type of reference and if we were to do any kind of thorough validation of them we'd probably flag them as invalid today.

Expected UX

Completion

Screenshot 2022-06-01 at 15 18 28

Hover

Screenshot 2022-06-01 at 15 18 38

Semantic Highlighting

Screenshot 2022-06-01 at 15 19 16

Proposal

@radeksimko radeksimko changed the title Support count.index references in relevant blocks Support count.index references in blocks w/ count Apr 7, 2022
@jpogran jpogran self-assigned this Sep 23, 2022
jpogran added a commit that referenced this issue Oct 18, 2022
Add changelog info for #860
radeksimko added a commit that referenced this issue Oct 18, 2022
* Update CHANGELOG

Add changelog info for #860

* Update CHANGELOG.md

Co-authored-by: Radek Simko <[email protected]>

Co-authored-by: Radek Simko <[email protected]>
@xiehan xiehan added this to the v0.30.0 milestone Oct 27, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2022
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.

3 participants