https://pulumi.com logo
Title
m

most-arm-49724

05/05/2023, 6:14 PM
^ Update. I've managed to sort that out but how can I spin up resources asynchronously? For eg: I spin the db up first and then i use those credentials for my app?
w

worried-rain-74420

05/06/2023, 3:00 AM
Once you create a DO Database Cluster, the return value will contain “Output” fields which include the database’s credentials. You can pass those Outputs into other resources as Inputs. For example, if you wanted to take an Output and run “psql”, you might use the Command provider, which lets you run a local executable. You can provide the credentials Output from DO as arguments. After the cluster is created, the Command will run with the database credentials.
m

most-arm-49724

05/06/2023, 8:11 AM
Yea, I get that but they both kinda start at the same time. Have any sample ts/js code I can take a look at?
My code:
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const cravin_db = new digitalocean.DatabaseCluster("ifc-cravin-database", {
engine: "mysql",
nodeCount: 1,
region: "blr1",
size: "db-s-1vcpu-1gb",
version: "8",
name: "ifc-cravin-database"
});
const cravin_server = new <http://digitalocean.App|digitalocean.App>("ifc-cravin", {spec: {
name: "ifc-cravin-server",
region: "blr1",
services: [{
github: {
branch: "main",
deployOnPush: true,
repo: "Anan7Codes*/repo*",
},
instanceCount: 1,
instanceSizeSlug: "professional-xs",
name: "ifc-cravin-server",
buildCommand: "npm run -w api build",
runCommand: "npm start -w api",
envs: [
{
key: "DB_URL",
`value: `mysql://doadmin:${cravin_db.password}@${cravin_db.host}:${cravin_db.port}/defaultdb?sslmode=no-verify``
}
]
}],
}});
Managed to sort this out using the dependOn method but the credentials from db aren't being passed to the DB_URL.