Skip to content

Unexpected attribute: An attribute named "for_each" is not expected here #2105

@Randdrick

Description

@Randdrick

Extension Version

v2.36.1

VS Code Version

Hello,
"for_each" instruction in imports under Terraform make an Unexpected attribute error: An attribute named "for_each" is not expected here

Bug has appeared since version 2.35.0.

Ex:

import {
  for_each = local.web_instances
  to       = aws_launch_template.web[each.key]
  id       = each.value[0]
}

Operating System

Ubuntu 22.04.5 LTS (WSL)

Terraform Version

Terraform v1.13.1 on linux_amd64

Steps to Reproduce

Upgrade to version v2.36.1
Use for_each instruction in import terraform structure

Expected Behavior

The for_each instruction must be able to work in an import under terraform.

Actual Behavior

Hello,
"for_each" instruction in imports under Terraform make an Unexpected attribute error: An attribute named "for_each" is not expected here

Bug has appeared since version 2.35.0.

Ex:

import {
  for_each = local.web_instances
  to       = aws_launch_template.web[each.key]
  id       = each.value[0]
}

Terraform Configuration

Project Structure

Gist

No response

Anything Else?

No response

Workarounds

No response

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