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

wonderful-napkin-50018

03/30/2021, 11:20 AM
I have an Input which includes a string array (
subnetIds
) and need to convert it to an
Input<string>[]
(so an array of string inputs). How can I do this?
Figured it out:
Copy code
export const publicSubnetIds = infra.requireOutputValue('publicSubnetIds');
export const publicSubnetId1 = pulumi.output(publicSubnetIds)[0];
export const publicSubnetId2 = pulumi.output(publicSubnetIds)[1];
l

little-cartoon-10569

03/30/2021, 7:46 PM
There's a few improvements that you can make there. requireOutputValue returns a Promise extracted from an Output, which you then immediately wrap in an Output (twice). So you can replace requireOutputValue with requireOutput and then drop the two calls to pulumi.output().
I'm not sure how
pulumi.output(publicSubnetIds)[0]
is working, since
pulumi.output(publicSubnetIds)
should be a Promise<string[]> which isn't indexable. If there's some Pulumi magic and lifting going on, then great. Otherwise, that might be compiling because of the magic of any? Is it working in this form?
I would probably be looking to await something in order to export subnet IDs from an awsx VPC...
w

wonderful-napkin-50018

03/31/2021, 12:06 PM
Can you use await in pulumi TS files?
I am not sure how it works either, but it does 😄
82 Views