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

damp-pillow-67781

04/23/2019, 3:58 PM
I’m following the example here, but this line doesn’t work, is there any way I can use the value in the output? https://github.com/pulumi/pulumi-aws/blob/master/sdk/nodejs/ec2/getSubnetIds.ts#L24
w

white-balloon-205

04/23/2019, 4:17 PM
Yes - that example unfortunately looks incorrrect. Here's something that works for me and does the same thing:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

async function getAllSubnets(): Promise<aws.ec2.GetSubnetResult[]> {
    const subnetIds = await aws.ec2.getSubnetIds({
        vpcId: "vpc-c93b06ae",
    });

    const results: aws.ec2.GetSubnetResult[] = [];
    for (const subnetId of subnetIds.ids) {
        const subnet = await aws.ec2.getSubnet({
            id: subnetId,
        });
        results.push(subnet);
    }

    return results;
}

export const allSubnets = getAllSubnets();
d

damp-pillow-67781

04/23/2019, 6:37 PM
This works, thanks!