late-journalist-61387
09/21/2023, 8:41 PMconst isPreview = pulumi.runtime.isDryRun();
if (!isPreview) {
rdsDataServer.endpoint.apply(rdsDataServerEndpoint => {
rdsDataServer.port.apply(rdsDataServerPort => {
....
// here we have received the rds host, user, password, ...
// now, we run the query to check if the user exist before
if(!userExistsDatabase("username"))
{
let secret = new aws.secretsmanager.Secret("...", {
// The name of the secret
name: "...",
tags: {
...
}
});
// create user in database with postgers library
// make an object to store the value
const storeKeyValue = {
dbUrl: ...,
}
// Setting a value for our secret
let secretValue = new aws.secretsmanager.SecretVersion("...", {
secretId: secret.id,
secretString: JSON.stringify(storeKeyValue),
});
}
}
}
it works well for the first time, however when I run the second time, as the user is created before and the secret creation code will not reach, pulumi tries to destroy that.
so what is the solution?