sparse-intern-71089
10/12/2022, 5:19 PMbillowy-army-68599
apply
- once you’re inside the apply
you can manipulate the string as you would any other stringbillowy-army-68599
uri
have the random string in there?few-carpenter-12885
10/12/2022, 5:22 PMusername:password@
section after the mongodb+srv://
section.few-carpenter-12885
10/12/2022, 5:23 PMreplace
function within an apply. Let me see if I can get back to that point.few-carpenter-12885
10/12/2022, 5:24 PMlittle-library-54601
10/12/2022, 5:29 PMsqlServerOutput
which is of type:
Output.Tuple<string, string, string> // aka
Output<(string, string, string)>
Using .Apply
looks like:
// Server=tcp:{server-name}.<http://database.windows.net|database.windows.net>,1433;Initial Catalog={db-name};Persist Security Info=False;User ID={login-name};Password={login-password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
return sqlServerOutput.Apply(t =>
{
(string server, string loginId, string loginPassword) = t;
return sqlDatabase.Name.Apply(finalDbName =>
$"Server=tcp:{server}.<http://database.windows.net|database.windows.net>,1433;Initial Catalog={finalDbName};Persist Security Info=False;User ID={loginId};Password={loginPassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
);
});
little-library-54601
10/12/2022, 5:29 PMsqlDatabase.Name
is another Output<string>
few-carpenter-12885
10/12/2022, 5:30 PMconst mongoDbUri = pulumi
.all([db.uri, db.user, db.password, db.name])
.apply(([uri, user, password, name]) => {
const [prefix, suffix] = uri.split('//')
return `${prefix}//${user}:${password}@${suffix}/${name}`
})
billowy-army-68599