https://pulumi.com logo
#general
Title
# general
d

damp-ram-18047

10/18/2021, 3:30 AM
Hi there, I deployed gcp cloud sql database user with random generated password, but I need to set the password in my env config file, how can I get the password?
l

little-cartoon-10569

10/18/2021, 3:44 AM
How did you generate the password? Using the Pulumi Random provider?
d

damp-ram-18047

10/18/2021, 5:54 AM
Yes
Copy code
import * as random from '@pulumi/random';

export const dbPassword =
   config.get('dbPassword') || genRandomPassword('dbPasswordGen', 8);

function genRandomPassword(
  name: string,
  length: number,
): pulumi.Output<string> {
  return new random.RandomString(name, {
    upper: false,
    number: true,
    special: true,
    length: length,
  }).result;
}
I found urn
gcp:sql:User
in stack resource, but the password length doesn’t match (
genRandomPassword('dbPasswordGen', 8);
)
gcp:sql:User
detail looks like
Copy code
{
  "__meta": "{\"..."}",
  "host": "",
  "id": "gcp-project-name//db-name",
  "instance": "web-db",
  "name": "username",
  "password": {
    "4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd": "1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0",
    "ciphertext": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7"
  },
  "project": "gcp-project-name",
  "type": ""
}
8 Views