This message was deleted.
# getting-started
s
This message was deleted.
b
use an
apply
- once you’re inside the
apply
you can manipulate the string as you would any other string
although: shouldn’t the
uri
have the random string in there?
f
The uri already has the random section. However, I need to insert the
username:password@
section after the
mongodb+srv://
section.
I was having an issue using the
replace
function within an apply. Let me see if I can get back to that point.
Ah, I might be able to do a split. Let me play with this a bit. Thanks for the help.
l
Here's my code to do similar for SQL Server... Given a variable
sqlServerOutput
which is of type:
Copy code
Output.Tuple<string, string, string>  // aka
Output<(string, string, string)>
Using
.Apply
looks like:
Copy code
// 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;"
            );
        });
Also,
sqlDatabase.Name
is another
Output<string>
f
Thanks. I think I got it working how I need in my case.
Copy code
const 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}`
        })
👍 1
b
language primitives ftw!
🙌 1