Hey guys! I have one stack where I create an AWS R...
# general
b
Hey guys! I have one stack where I create an AWS RDS cluster and export its writer endpoint as an output variable. In another stack I fetch the output and want to pass the RDS writer endpoint as an DB connection string to a k8s job. No matter what I do, pulumi does not print the value of the output variable but "Calling [toString] on an [Output<T>] is not supported." What am I doing wrong? Note that using "apply" is not working also because its return type is Output<string>, so the problem remains. Any hint is highly appreciated
To answer my own question, I had to use StackReference.getOutputSync(name) instead of getOutput(name)
f
Probably better is to use apply with the k8s job inside the apply (since as you saw, apply’s return an Output)
the synchronous functions will be going away in pulumi 2.0
b
Hi Lee, thanks for your hints but I don't get it 🙂 could you give an example? I want to create a k8s job (or deployment) and use the output from another stack concatenated with other strings as a container argument (i.e. add prefix and suffix).
f
Something like:
Copy code
const stackRef = pulumi.StackReference(`acmecorp/infra/${env}`)
const containerArg = pulumi.interpolate`${prefix}${stackRef.getOutput("foo")}${suffix}`

...

const service = new k8s.core.v1.Service(name, {
    ...
    metadata: {
        annotations: {
            "foo": containerArg
        }
    }
}
containerArg will be a
pulumi.Output<string>
which you can pass as a
pulumi.Input<string>
as an argument to your resources
b
Thanks Lee, I'll try it 🙂