Skip to content

Add some resource attributes from stackit_postgresflex_user also to stackit_postgresflex_instance ? #1074

@mardonner

Description

@mardonner

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions