Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Pulumi, exist a equivalent to pulumi.Output.apply, but to transform pulumi.Input values?

I'm developing a Pulumi ComponentResource named CopyPostgresql in Typescript.

CopyPostgreSql is a Kubernetes job that copy in streaming the content of a source Postgresql database to a target Postgresql database. The options of CopyPostgreSql include properties source and target. Both are of type DatabaseInput.

export interface DatabaseInput {
    readonly port: Input<number>;
    readonly user: Input<string>;
    readonly password: Input<string>;
    readonly host: Input<string>;
    readonly dbname: Input<string>;
}

So, i want to use port as value of another property from another component, but that another property is of type Input< string >.

How can i apply (or transform) a value of type Input< number > to Input< string >? and in general: In Pulumi, exist a equivalent to pulumi.Output.apply, but to transform pulumi.Input values?

like image 758
gabomgp Avatar asked Nov 01 '25 04:11

gabomgp


1 Answers

You can do pulumi.output(inputValue).apply(f).

So, you can flow them back and forth:

const input1: pulumi.Input<string> = "hi";
const output1 = pulumi.output(input1);
const output2 = output1.apply(s => s.toUpperCase());
const input2: pulumi.Input<string> = output2;
like image 195
Mikhail Shilkov Avatar answered Nov 03 '25 19:11

Mikhail Shilkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!