Obtain resource address for error message

In my data source object, I check to make sure it resolves to a single entity. if it doesn’t, I print out an error message. However, I would like to specify which data source object cannot resolve to a single entity for the end user to fix. I can’t find a way to obtain the resource address (not the ID), like aws_ami.MyAMI, of the data source.

This isn’t currently possible, but is something we’re discussing over the longer term. But the address (and more) information should already be surfaced to the user when you return an error. Is that not happening for you?

No that is not happening, but maybe because I am not returning the error properly. I just return a diag.Errorf(“my error statement”) but then that is all I see in the TF output so I can’t tell which resource has the error to know what to fix.