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

brave-angle-33257

08/21/2019, 10:56 PM
having hard time again with outputs.. in my VPC stack, i output the aws zones being used from a simple object property, it’s defined as:
Copy code
subnet_zone_letters:string[] = ['a', 'b', 'c', 'd'];
I want to make sure the other stack uses the same values, so I pass them as an output:
Copy code
export let vpc_subnet_zone_letters = vpc.subnet_zone_letters;
that shows up in my outputs like:
Copy code
vpc_subnet_zone_letters: [
                [0]: "a"
                [1]: "b"
                [2]: "c"
                [3]: "d"
            ]
Finally, in another stack I want to load them and use them as part of a string input to another stack, and so far for the life of me I can’t get it to work:
Copy code
var vpc_subnet_zone_letters = vpc.getOutput('vpc_subnet_zone_letters');
    ...
    availabilityZones: [
        `us-east-2${vpc_subnet_zone_letters.apply(x=>`${x[0]}`)}`,
        `us-east-2${vpc_subnet_zone_letters.apply(x=>`${x[1]}`)}`,
    ],
Copy code
~ availabilityZones          : [
          ~ [0]: "us-east-2a" => "us-east-2Calling [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.\nThis function may throw in a future version of @pulumi/pulumi."
          ~ [1]: "us-east-2b" => "us-east-2Calling [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.\nThis function may throw in a future version of @pulumi/pulumi."
        ]
looks like this works:
Copy code
availabilityZones: vpc_subnet_zone_letters.apply( x => [
           `${region}${x[0]}`,
           `${region}${x[1]}`
        ]),
so, seems like really the only way a lot of this works is to let the magic happen inside of the resource and not anywhere on the outside of things, i.e. they never resolve outside of a pulumi resource, which I guess makes sense, so don’t try it lol.
b

best-xylophone-83824

08/22/2019, 9:41 AM
try
Copy code
pulumi.interpolate`us-east-2${vpc_subnet_zone_letters[0]}`
b

brave-angle-33257

08/22/2019, 3:44 PM
tried it just to see.. I know I did try some
interpolate
commands, but it fails:
Copy code
availabilityZones: [
            `us-east-2${pulumi.interpolate `vpc_subnet_zone_letters[0]`}`,
            `us-east-2${pulumi.interpolate `vpc_subnet_zone_letters[1]`}`
        ],
Copy code
availabilityZones          : [
            [0]: "us-east-2Calling [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.\nThis function may throw in a future version of @pulumi/pulumi."
b

best-xylophone-83824

08/22/2019, 3:46 PM
try
Copy code
pulumi.interpolate`us-east-2${vpc_subnet_zone_letters[0]}