https://pulumi.com logo
#aws
Title
# aws
s

stale-answer-34162

01/03/2024, 12:54 AM
how can I export the
manageMasterUserPassword
value either a pulumi id or arn?
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.rds.Cluster("test", {
    clusterIdentifier: "example",
    databaseName: "test",
    manageMasterUserPassword: true,
    masterUsername: "test",
});
g

green-stone-37839

01/03/2024, 1:17 AM
I've not tested this program yet, but I believe you can use the following two lookup calls to retrieve the AWS created value
Copy code
import * as aws from "@pulumi/aws";

const test = new aws.rds.Cluster("test", {
    engine: "aurora-mysql",
    clusterIdentifier: "example",
    databaseName: "test",
    manageMasterUserPassword: true,
    masterUsername: "admin",
    skipFinalSnapshot: true,
});

// NOTE: this example assumes the masterUserSecrets array will ALWAYS have a single instance in it.
// lookup our the created secret and its current version, then export the needed value(s).
const secret = aws.secretsmanager.getSecretOutput({
    arn: test.masterUserSecrets.apply(masterUserSecrets => masterUserSecrets[0].secretArn),
});

const secretVersion = aws.secretsmanager.getSecretVersionOutput({
    secretId: secret.id,
});

export const password = secretVersion.secretString;