Skip to content

No declaration found for "local" when "local" is used as a variable in a for loop #1690

Open
@mymasse

Description

@mymasse

Language Server Version

v0.33.0

Terraform Version

Terraform v1.8.0 on linux_amd64

Client Version

VSCode 1.87.0

Terraform Configuration

locals {
  repos = {
    local = {
      "repo1" = {
        description = "repo1"
      }
    }
    remote = {
      "repo2" = {
        description = "repo2"
      }
    }
    virtual = {
      "repo3" = {
        description = "repo3"
      }
    }
  }
}

resource "artifactory_virtual_debian_repository" "this" {
  for_each = local.repos.virtual

  key         = each.key
  description = each.value.description

  repositories = [
    concat(
      [for local in artifactory_local_debian_repository.local: local.key],
      [for remote in artifactory_local_debian_repository.remote: remote.key]
    )
  ]
}

Steps to Reproduce

  1. Open VSCode
  2. Create a main.tf with the above content

Expected Behavior

No warning are displayed (none did in version prior to 0.33.0). Terraform applies this configuration as expected with no errors.

Actual Behavior

Problem listed for the following line:

Line: [for local in artifactory_local_debian_repository.local: local.key],
Error: No declaration found for "local.key"

Gist

No response

Workarounds

Changing [for local in artifactory_local_debian_repository.local: local.key], to [for local_repo in artifactory_local_debian_repository.local: local_repo.key], removes the problem.

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions