having hard time again with outputs.. in my VPC st...
# general
b
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
try
Copy code
pulumi.interpolate`us-east-2${vpc_subnet_zone_letters[0]}`
b
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
try
Copy code
pulumi.interpolate`us-east-2${vpc_subnet_zone_letters[0]}