sparse-intern-71089
09/23/2020, 6:12 PMgreen-school-95910
09/23/2020, 6:13 PMapply
, or change the specific portion inside of it that uses the string to use apply
green-school-95910
09/23/2020, 6:15 PMget()
on the outputhundreds-receptionist-31352
09/23/2020, 6:48 PMgreen-school-95910
09/23/2020, 6:57 PMnew theResource(..., {
callbackFactory: () => {
const lb2 = value.get();
return () => customFunction(lb2);
}
});
If it is part of the deployment:
// customFunction(lb2: string): T
value.apply(lb2 => customFunction(lb2)) // returns Output<T>
Even better if you change the code of the function to accepts a Input<string>
instead of only a string
, and apply transformations on it as needed, for example:
interface KV {
key: string;
value: string;
}
// before
function splitKeyValue(s: string): KV {
const [k, v] = s.split(':', 1);
return {key: k, value: v};
}
// after
function newSplitKeyValue(s: pulumi.Input<string>): pulumi.Output<KV> {
const pair = output(s).apply(s => s.split(':', 1));
return pair.apply(([key, value]) => ({key, value}));
}
green-school-95910
09/23/2020, 6:59 PMgreen-school-95910
09/23/2020, 7:00 PMconst keyPair: pulumi.Output<KV> = newSplitKeyValue('a:b');
const justKey: pulumi.Output<string> = keyPair.apply(kv => kv.key);
green-school-95910
09/23/2020, 7:01 PMgreen-school-95910
09/23/2020, 7:02 PM