https://pulumi.com logo
#typescript
Title
# typescript
m

magnificent-lifeguard-15082

01/06/2022, 5:21 PM
ec2.Vpc.getSubnets
returns a
Promise<ec2.Subnet[]>
as opposed to an
Output<ec2.Subnet>[]
. Is this safe to use as an arg (Input) to a subsequent resource where I need to provide a subnet id?
b

billowy-army-68599

01/06/2022, 5:22 PM
we have the new
ec2.Vpc.getSubnetsOutput
which might be more helpful in this scenario
m

magnificent-lifeguard-15082

01/06/2022, 5:28 PM
Ah, doesn't look like it's on my version awsx.Vpc (sorry should've mentioned this is awsx)
b

billowy-army-68599

01/06/2022, 5:31 PM
oh, sorry yes it's not in there yet
and no, you can't pass a promise to an Output, you'll need to await it and then build an output, which won't be fun
m

magnificent-lifeguard-15082

01/06/2022, 5:34 PM
yeah sounds like bad things will occur 😅
Copy code
vpc.id.apply(() => vpc.publicSubnets)
wrap in a relateed output to maintain dependency data, return promise to subnets which should resolve some time after vpc.id
(in my head)
r

red-family-60032

03/28/2022, 12:14 PM
What @magnificent-lifeguard-15082 suggested worked as a charm ❤️
Copy code
const publicSubnetsIds = vpc.id.apply(async () => vpc.getSubnetsIds("public"));
and then I use it like this:
Copy code
const alb = new aws.lb.LoadBalancer(`${name}-alb`, {
      internal: false,
      loadBalancerType: "application",
      securityGroups: [albSecGroup.id],
      subnets: publicSubnetsIds.apply((ids) => ids),
    });
Thanks a bunch, @magnificent-lifeguard-15082!
❤️ 1
e

echoing-dinner-19531

03/28/2022, 3:53 PM
publicSubnetsIds.apply((ids) => ids),
is the same as just
publicSubnetsIds
👍 1
r

red-family-60032

03/28/2022, 5:40 PM
hmhmh, this confuses me my IDEA says something else:
b

billowy-army-68599

03/28/2022, 5:43 PM
does this not work?
Copy code
const alb = new aws.lb.LoadBalancer(`${name}-alb`, {
      internal: false,
      loadBalancerType: "application",
      securityGroups: [albSecGroup.id],
      subnets: publicSubnetsIds
    });
r

red-family-60032

03/28/2022, 5:45 PM
Oh, got it - it does 😄
thanks!
4 Views