Why does refresh not show my resource id?

I recently made my first provider and it works as expected. But I have noticed that when I use it in my configuration, during the refresh step of apply/plan, it looks like this:

gotify_client.dashboard: Refreshing state... [name=Dashboard Widget]
module.gotify.kubernetes_service.web_service: Refreshing state... [id=apps/gotify]
gotify_application.diun: Refreshing state... [name=Diun]
module.gotify.kubernetes_deployment.app: Refreshing state... [id=apps/gotify]
module.gotify.kubernetes_ingress_v1.web_ingress: Refreshing state... [id=apps/gotify]

As you can see, all of my resources (gotify_client and gotify_application) use the name field to identify the resource in the output (its just the output, right?) while all other resources (from various providers) show the id field.

Both my resources also have an id field which I’m also internally using to keep track of them. I’m wondering what causes this output to look like this. I can’t find anything in the schema.Attribute to give a hint to Terraform and the order in the code doesn’t seem to influence this.

Here is my Resource Schema (and all the rest of the code) from the example above.

You’ll be interested in ObjectValueId() here.

Your id attribute is a types.Int64, so it’s being ignored. Second choice attribute name is a types.String in your provider, so that’s used instead.

Thanks for clarifying that, two follow-up questions:

  1. This is really only for displaying purposes, correct? It has no bearing on what Terraform uses internally to save my state (as far as I understand, thats all in my logic anyways).
  2. There is no way to override this or tell Terraform to use the ID?

I’m wondering if it’s worth to change my Id to String and cast the API values from int to string. If it’s for output only, probably not…

Context: I’m not an authority on anything. I’m just pretty good at git grep

  1. That’s my read of the function’s Go doc comment.
  2. :person_shrugging:

Correct, the CLI output you are referring to has no bearing on how Terraform handles the data, it’s just using some simple heuristics to guess what might be a human readable identifier.