https://pulumi.com logo
Title
a

astonishing-artist-72290

11/07/2022, 9:29 AM
Hello, Can somebody please help with printing/accessing in debugger list of AWS subnets? I'm stuck (( Here is how I get list of the subnets, but I don't understand on how to print that list and how to access it's values in the debugger (I'm using vscode)
const aws = require("@pulumi/aws");

const tagsPrivate: { [key: string]: string } = {
  EKS_Cluster: eksOpts.name,
  Type: 'private'
};

const privateSubnetIds = aws.ec2.getSubnetsOutput(tagsPrivate).apply(sn =>  sn.ids);

// this doesn't work, I'm getting "Private subnet IDs: Calling [toString] on an [Output<T>] is not supported."
<http://pulumi.log.info|pulumi.log.info>(`Private subnet IDs: ${privateSubnetIds}[0]`);
Thanks
e

echoing-dinner-19531

11/07/2022, 9:54 AM
Put the log inside an apply:
privateSubnetIds.apply(ids => <http://pulumi.log.info|pulumi.log.info>(`Private subnet IDs: ${ids}[0]`))
a

astonishing-artist-72290

11/07/2022, 9:59 AM
wow, that worked, thanks a lot! Do you know why this syntax works and my form didn't?
e

echoing-dinner-19531

11/07/2022, 10:00 AM
Because as the error message says you can't meaningfully call toString on an Output<T>. An output is kind of like a promise so you have to wait for it's result (by using apply).
a

astonishing-artist-72290

11/07/2022, 10:01 AM
Right, so you mean that this
aws.ec2.getSubnetsOutput(tagsPrivate).apply(sn =>  sn.ids)
will not really return list of ids ?
e

echoing-dinner-19531

11/07/2022, 10:02 AM
It will return an Output of a list of ids
a

astonishing-artist-72290

11/07/2022, 10:02 AM
I see, thanks a lot
e

echoing-dinner-19531

11/07/2022, 10:02 AM
a

astonishing-artist-72290

11/07/2022, 10:03 AM
Awesome! 🙇‍♂️