Skip to content

Instantly share code, notes, and snippets.

@atazangene
Created September 22, 2023 09:43
Show Gist options
  • Save atazangene/b0cac09cbde0337d1ab57b24f396bd9c to your computer and use it in GitHub Desktop.
Save atazangene/b0cac09cbde0337d1ab57b24f396bd9c to your computer and use it in GitHub Desktop.
setup db
// as we have saved all information inside the secret manager, we can get them here
const rdsRootPasswordSecretKeyOutput = aws.secretsmanager.getSecretOutput({
arn: rdsDataServer.masterUserSecrets[0].secretArn
})
const rdsSecretVersion = aws.secretsmanager.getSecretVersionOutput({
secretId: rdsRootPasswordSecretKeyOutput.id
})
// now, we can get the secret value
const secretValue = rdsSecretVersion.secretString
// PROBLEM IS HERE, I need to use JSON.parse to get the username and value
// however as the secretValue is pulumi.Output<string> type, I am not able to use The JSON.parse here
const parsedSecret = secretValue.apply(sv => {
const parsed = JSON.parse(sv)
return {
username: parsed.username as string,
password: parsed.password as string
}
})
// now, we have username and password of root user, we need to pass it to function
// that creates new user and setup secret manager for that
initBaseDatabaseSetup(rdsDataServer.address, rdsDataServer.port, parsedSecret.username, parsedSecret.password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment