Hey folks, what is the way to get the value out of...
# general
l
Hey folks, what is the way to get the value out of pulumi/random? I tried using apply and pulumi output, just keep getting an error
Calling [toJSON] on an [Output<T>] is not supported. To get the value of an Output as a JSON value or JSON string consider either: 1: o.apply(v => v.toJSON()) 2: o.apply(v => JSON.stringify(v)) See <https://pulumi.io/help/outputs> for more details. This function may throw in a future version of @pulumi/pulumi.
g
Try this
Copy code
xxx = pulumi.Output.fromInput(
{
    AURORA_USERNAME: rdsUsername,
   AURORA_PASSWORD: rdsPassword
}
).apply(JSON.stringify)
Then you should be able to pass
xxx
to
secretString
l
@great-sunset-355
Copy code
index.ts(651,35): error TS2339: Property 'fromInput' does not exist on type 'OutputConstructor'.
g
you'll need to find the right in TS, I'm using python so it may not always translate directly. This is what the method does in python
Copy code
"""
        Takes an Input value and produces an Output value from it, deeply unwrapping nested Input values through nested
        lists, dicts, and input classes.  Nested objects of other types (including Resources) are not deeply unwrapped.

        :param Input[T_co] val: An Input to be converted to an Output.
        :return: A deeply-unwrapped Output that is guaranteed to not contain any Input values.
        :rtype: Output[T_co]
        """
You should find TS equivalent here: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#Input
l
nvm, you gave me an idea, it is working now
Copy code
const auroraCreds = pulumi.all([rdsUsername.result, rdsPassword.result])
  .apply(([username, password]) => {
    JSON.stringify({ AURORA_USERNAME: username, AURORA_PASSWORD: password })
  })
g
👍
it takes some time to absorb
apply()
252 Views