https://pulumi.com logo
#general
Title
# general
b

brave-angle-33257

04/02/2020, 5:54 PM
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

cool-egg-852

04/02/2020, 5:59 PM
Instead of
.apply
there, do
Copy code
pulumi.interpolate`…`
I think that will fix it
b

brave-angle-33257

04/02/2020, 6:01 PM
it wont let me do pulumi.interpolate in the middle of the userData string
c

cool-egg-852

04/02/2020, 6:02 PM
Not in the middle of it, you do it around it.
Copy code
userData: pulumi.interpolate`...`
b

brave-angle-33257

04/02/2020, 6:03 PM
ah, ok let me test
it works! thank you 🙂
c

cool-egg-852

04/02/2020, 6:04 PM
No problem
b

brave-angle-33257

04/02/2020, 6:04 PM
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

cool-egg-852

04/02/2020, 6:05 PM
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

brave-angle-33257

04/02/2020, 6:06 PM
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

cool-egg-852

04/02/2020, 6:07 PM
Yep, always the most difficult part for me too.
2 Views