Hi there, I deployed gcp cloud sql database user w...
# general
d
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
How did you generate the password? Using the Pulumi Random provider?
d
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": ""
}