This message was deleted.
# general
s
This message was deleted.
g
If this function is executed during the deployment you can run the function inside of
apply
, or change the specific portion inside of it that uses the string to use
apply
If it is being used in a serialized function (deployed to lambda, gcf, etc.), then you can call
get()
on the output
h
Would you have an example to follow?
g
If it is a serialized function, something like this:
Copy code
new theResource(..., {
  callbackFactory: () => {
    const lb2 = value.get();
    return () => customFunction(lb2);
  }
});
If it is part of the deployment:
Copy code
// 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:
Copy code
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}));
}
Instead of manipulating everything all at once, you can transform it as needed
Copy code
const keyPair: pulumi.Output<KV> = newSplitKeyValue('a:b');
const justKey: pulumi.Output<string> = keyPair.apply(kv => kv.key);
The difference is that those values are only calculated when traversing the graph of resources, not when building it
So if you need to get some external resources, this is a good way to do it since it will not interfere with pulumi building the dependency graph