terraform-provider-stackit icon indicating copy to clipboard operation
terraform-provider-stackit copied to clipboard

Add some resource attributes from `stackit_postgresflex_user` also to `stackit_postgresflex_instance` ?

Open mardonner opened this issue 1 month ago • 1 comments

Hi, when interacting with the postgres resources I was a little confused why some resource attributes that I expected on stackit_postgresflex_instance are actually to be found on stackit_postgresflex_user.

For example, I expected to find:

  • host
  • port

On the instance's resource and not the user's resource. Is there a specific reason for that?

Arguing from a resource hierarchy point of view, is it even possible for two users on the same instance to have a different port and host? I'm not arguing that they shouldn't have these attributes. I just don't understand why the user resource is the only source for this info and not the instance itself. Or arguing the inverse: Can one postgres instance even be available on multiple hosts and ports?

I stumbled upon this because I wanted add details about my postgres instances in my root module's output. For me it'd make more sense to iterate over the instances to get this information than the users. Right now, if I use the instances, I have to assemble the host info myself by guessing that it'll be this:

"${stackit_postgresflex_instance.pgflx[spec.instance_name].instance_id}.postgresql.${stackit_postgresflex_instance.pgflx[spec.instance_name].region}.onstackit.cloud"

The other option would be to iterate over my users and reference

stackit_postgresflex_user.admin_user[spec.instance_name].host

and then filter out the duplicates in case of multiple users on the same instance.

Directly referencing a resource attribute is the best way to get this info because then I don't have to guess that it'll be <instanceID>.postgres.<region>.onstackit.cloud but have it guaranteed.

Do you understand what I mean?

Edit: This would be more of an issue if the host url would be non-predictable like how it works with observability where I can't know know the stackitXX part in the url before creation.

mardonner avatar Nov 27 '25 09:11 mardonner

Hello @mardonner,

thanks for reporting this issue. In the terraform provider we are limited to the information we are getting from the api itself. In case of the postgresflex instance, the GET endpoint doesn't provide the host and port. (See api docs)

I will forward your request to the PostgreSQL Flex Team.

Best regards Marcel from the STACKIT Developer Tools Team

marceljk avatar Nov 27 '25 12:11 marceljk