Should I use id or self_link when reference resource

Hi all,

I am confused about resource id and self_link attributes, I have tried in my code and they can be used interchangeably in reference: I would like to know if there is any rule or best practice I need to follow to use them?

From the definition, looks they point to the same object but with different format (please correct me if I am wrong:-)):

  • id: an identifier of the resource
  • self_link: the URI of the resource.

Thanks in advance!

Hi @chengdol,

self_link attributes are a convention specific to the Google Cloud Platform provider, rather than something general to Terraform, and so the relevant advice about this is in the Google Cloud Platform provider’s documentation: Linking GCP resources.

Thank you @apparentlymart to clarify!