can anyone help why this isnt working: ```var buck...
# general
b
can anyone help why this isnt working:
Copy code
var bucket_name = <pulumi.Output<string>>s3.getOutput(`bucket_backup`);
var instance = new aws.ec2.Instance('instance', {
   ...
     userData: `
    #! /bin/bash
    # create template for deployment
    cat > vpnbackup.sed <<SED
    s|--BUCKET-NAME--|${bucket_name.apply(v=>v)}|
    ...
"Calling [toString] on an [Output<T>] is not supported.\n\nTo get the value of an Output<T> as an Output<string> consider either\n1 o.apply(v =>
prefix${v}suffix
)\n2: pulumi.interpolate `prefix${v}suffix`\n\nSee https://pulumi.io/help/outputs for more details."
😎 1
c
Instead of
.apply
there, do
Copy code
pulumi.interpolate`…`
I think that will fix it
b
it wont let me do pulumi.interpolate in the middle of the userData string
c
Not in the middle of it, you do it around it.
Copy code
userData: pulumi.interpolate`...`
b
ah, ok let me test
it works! thank you 🙂
c
No problem
b
i dont understand why this doesn't work as written, seems much more intuitive that way
the error message isn't exactly clear either
regardless, thanks again
c
The thing is the value.
.apply
will return an
Output
, but then the whole value of
userData
is not a
Output<>
type. By interpolating the entire thing, you tell Pulumi to parse the entire value, then return it as an
Output
I do agree the error message could be a lot better. I’ve struggled with this myself a lot.
b
yes, outputs/strings is the biggest area of issue I have even after > 12 months of using pulumi! i feel like each situation is a bit different
c
Yep, always the most difficult part for me too.