i want to create a postgres cluster, and then reus...
# golang
w
i want to create a postgres cluster, and then reuse that pg cluster across stacks this requires that the creator stack exports info on how to connect to the cluster when it comes to the provider, this is easy-- the consumer stack can just use
pulumi.NewStackReference(...).GetProvider("pg-provider-id")
however, the consumer stack also needs raw connection info (host, port, etc) in order to inject that info into kubernetes pods, so that the pods can connect to pg at runtime. this is where it gets tricky... • is there some way to get
postgresql.ProviderArgs
out of the provider, during pulumi runtime? • is there some easy way to marshal/unmarshal
postgresql.ProviderArgs
, so that i can use a string stack export? keep in mind there are no pulumi types (input/output) defined for
postgresql.ProviderArgs
-- that's just a struct containing a bunch of pulumi types tia 🙏
l
Have you read the programming model docs on
Apply
? https://www.pulumi.com/docs/intro/concepts/programming-model/#apply You can use a combination of
All
and
Apply
to transform a bunch of pulumi properties (
pulumi.String
,
<http://pulumi.Int|pulumi.Int>
, etc) into a new output value that is exportable.
w
yep, and that's my current approach, however it's 100+ LOC just to serialize/deserialize a bunch of fields to/from JSON there may be a better way?
l
Can you link to the struct? Which package are you using?
w
sorry for the delay, i missed your reply >.< i ended up: • using getProvider from the consumer stack to create pg users-- this gives me username + password • exporting/importing host, port, sslmode