How do we use apply properly to get strings for ou...
# typescript
How do we use apply properly to get strings for outputs? Struggling to work out what I'm missing here. Trying to get the connection URL from the RDS postgres output.
Copy code
export const db = new aws.rds.Instance(`${config.PROJECT_NAME}-postgres`, {
  engine: "postgres",
  instanceClass: "db.t2.small",
  allocatedStorage: 20,
  vpcSecurityGroupIds: [],
  name: config.POSTGRES_DB_NAME,
  username: config.POSTGRES_USERNAME,
  password: config.POSTGRES_PASSWORD,
  skipFinalSnapshot: true,
  publiclyAccessible: true

const username = db.username.apply(un => `${un}`);
const password = db.password.apply(pw => `${pw}`);
const address = db.address.apply(addr => `${addr}`);
const port = db.port.apply(port => `${port}`);
const name = => `${name}`);

const connectionUrl = `postgres://${username}:${password}@${address}:${port}/${name}`;

// Create a secret from the DB connection
export const dbConn = new k8s.core.v1.Secret(
    data: {
      dbConnectionUrl: Buffer.from(connectionUrl).toString("base64")
  { provider: cluster.provider }
I think what you are after is in the docs here:
Copy code
// concat takes a list of args and concatenates all of them into a single output:
const url1: Output<string> = pulumi.concat("http://", hostname, ":", port, "/");
// interpolate takes a JavaScript "template literal" and expands outputs correctly:
const url2: Output<string> = pulumi.interpolate `http://${hostname}:${port}/`;
Problem is that comes out as a Output<string>. Don't I need it as a string string to convert it to a base64 encoded secret.
can you use
yourStringOutput.apply(str => convertToBase64(str))
Brilliant. Yes that works. Thanks @limited-rainbow-51650 and @broad-helmet-79436 😄
🎉 1