Skip to content

Index variable value not shown when reporting "Invalid index" error #33109

Open
@jmouka

Description

Terraform Version

Terraform v1.4.6

Use Cases

When using a for_each and there is a missing or invalid index, Terraform should print out the actual value that's causing the issue. Instead the error is

Error: Invalid index
│   on ../modules/users/usersModule.tf line 117, in resource "okta_group_memberships" "mygroup":
│  117:   users = [for username in each.value.users: okta_user.users[username].id ]
│     │ okta_user.user is object with 727 attributes
│ The given key does not identify an element in this collection value.

Attempted Solutions

Basically I need to manually find the missing key. My terraform project has 727 values for this resource...

Proposal

It would be nice to see the actual resource ID, eg The given key "john123" does not identify an element in this collection value.

References

No response

Metadata

Assignees

No one assigned

    Labels

    bugconfignewnew issue not yet triagedv1.4Issues (primarily bugs) reported against v1.4 releases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions