Ah, postgres. I'm using this for managing users, <...
# general
d
Ah, postgres. I'm using this for managing users, https://www.pulumi.com/registry/packages/postgresql/api-docs/role/
l
I am using the Postgres
d
(sorry, thought I'd replied in thread before). Are there cases where the user will exist but not be owned by pulumi?
l
nope really, however I am not doing just create user, I am creating the a postgress schema ( public schema) and extension:
Copy code
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
can I manage do these with pulumi-postgres library?
d
Extensions, yes. Looks like it can create the schema, but can't do tables if that's what you're looking for
l
no, I do not want to do tables at this time
that is pretty cool that pulumi can handle everything
b
l
thanks @billowy-army-68599 it help me a lot
Hi, I came across another problem. I have changed my code to use your own postgress library, however the problem is that I am not able to set the postgress connection details programmable, in my scenario, I am going to 1. create RDS in AWS and store the password using the secret manager 2. after creation, get the password from the secret manager ( I find the secret resource with database tag ) 3. create role and user with for new created RDS server however the problem is there is not way ( at least not documented ) to set the host, username, password for the postgress server so I can connect to that and setup my Role and Schema.
@dry-keyboard-94795 do you know the answer pls
d
Every provider will have a provider resource you can configure: https://www.pulumi.com/registry/packages/postgresql/api-docs/provider/
l
perfect
Thank you
d
l
Nice, it works well. just to optimize my code, can you please see is this the only solution for me ? I tried to get the connection details and username and password in nested way, is there anyway not to use apply? https://jsfiddle.net/gvwuj46t/1/
d
Can you paste somewhere else, like gist.github.com, please? Jsfiddle is unusable on mobile
l
a moment pls
the problem with this code is that when I run pulumi in previews, as it is in dry run mode, it does not detect the resources I want to manage, so it says that they will be deleted
d
It looks like you can get the secrets manager arn through the rds instance outputs: https://www.pulumi.com/registry/packages/aws/api-docs/rds/instance/#masterusersecrets_nodejs
This should remove the need for your lookup code
l
ohhh, that is amazing
however for getting the host and port, I still need apply method
right?
d
Those are outputs on the rds instance also
You can pass those in directly to the postgres provider without going through
.apply
. Pulumi will deal with waiting for resources to be ready
l
great, I will try and let you know the result
d
You won't need the isPreview check after those changes are made, too
l
yes, my main problem is the isPreview function
Your solutions works find and everything is successfully setup now. Special Thanks for that, however there is still very tiny problem • the problem is that when I get the value of root from secret manager, it is in json format, and I need to parse it with JSON.parse, however the value is pulumi.Output<string>. I have used the apply function now, is it correct? https://gist.github.com/atazangene/b0cac09cbde0337d1ab57b24f396bd9c
d
Yep, this is the way to do it
l
Great, Thank you
d
Apply is to let you do this kind of transform. You'll likely use it for building ARNs or policy documents