https://pulumi.com logo
#golang
Title
# golang
w

wet-egg-6347

08/28/2020, 7:47 PM
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

lemon-agent-27707

08/28/2020, 8:00 PM
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

wet-egg-6347

08/28/2020, 8:02 PM
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

lemon-agent-27707

08/28/2020, 8:37 PM
Can you link to the struct? Which package are you using?
w

wet-egg-6347

09/28/2020, 8:11 PM
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
3 Views