I have an Input which includes a string array (`su...
# general
w
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
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
Can you use await in pulumi TS files?
I am not sure how it works either, but it does 😄
100 Views