https://pulumi.com logo
b

billions-lock-80282

07/29/2020, 2:03 PM
Hi, I've just updated to Pulumi 2 and fixing up the new asynchronous code. How do I access a single subnet in an array of subnets of type
Promise<pulumi.Output<string>[]>
? This is for an ec2 instance subnet field.
I used to have
subnetId: vpc.publicSubnetIds[0]
s

salmon-ghost-86211

07/31/2020, 6:18 PM
You could try something like
Copy code
subnetId: vpc.publicSubnetIds.apply(s => s[0])
or maybe
Copy code
const subnet = vpc.publicSubnetIds.then((subnetId: string[]) => { return subnetId[0]});
b

billions-lock-80282

08/05/2020, 10:03 AM
thanks, I'll try that