When writing a terraform module I often run in errors like this:
Error: Invalid index
on ../../../modules/host/main.tf line 7, in resource "aws_network_interface" "host":
7: subnet_id = data.aws_subnet_ids.current[each.key].ids[0]
|----------------
| data.aws_subnet_ids.current is object with 2 attributes
| each.key is "lab"
There are all kinds of reasons why this happens. Usually it is because what I think a certain object will contain is incorrect.
In order to help debugging this it would be usefull to at least see what the object contains. "Object with 2 attributes" is rather vague. I would like to know what attribtues it has, so I can add the necessary transformations to end up with the string I need here.
So is there a way? Can you in some way run "terraform plan" in such that the contents of those objects are actually displayed when the plan runs in to an error?