This message was deleted.
# typescript
s
This message was deleted.
m
Sorry, I do not have a good answer on the architecture part, but I can say that I've run into similar confusion over this awsx component myself, and I'm interested in understanding more about this particularly component for my use case. I was attempting to get a subnet in a vpc by availability zone.
Copy code
const vpc = new awsx.vpc.fromExistingIds("shared-vpc", {
  privateSubnetIds,
  publicSubnetIds,
  vpcId,
});

const thisSubnetId = pulumi.output(
  vpc.vpc.publicSubnets
    .get()
    .then((subnets: awsx.ec2.Subnet[]) =>
      subnets.find((subnet: awsx.ec2.Subnet) => subnet.subnet.availabilityZone === pulumi.output("us-east-1a")),
    ),
);

console.log(thisSubnetId.apply(v => v));
c
I’d have to play around with this, but I can confidently tell you that your subnet IDs are in an array thats pushed onto in AZ order. so index 0 is always a, 1 is b, and so on. (I know that’s a horrible answer 🤣 )
hey @millions-furniture-75402 here’s what I came up with for an actual answer to your question. hope it helps!
Copy code
import * as awsx from "@pulumi/awsx";

const vpc = new awsx.ec2.Vpc("test-vpc", {});

const ue1aPubSub = vpc.publicSubnets.then((a) => {
  return a
    .filter((s) => s.subnet.availabilityZone.apply((az) => az === "us-east-1a"))
    .pop()?.id;
});

export const out = {
  vpcId: vpc.id,
  vpcPubSubIds: vpc.publicSubnetIds,
  vpcPrivSubIds: vpc.privateSubnetIds,
  vpcDataSubIds: vpc.isolatedSubnetIds,
  vpcPubSubCidrs: vpc.publicSubnets.then((a) =>
    a.map((s) => s.subnet.cidrBlock)
  ),
  vpcPrivSubCidrs: vpc.privateSubnets.then((a) =>
    a.map((s) => s.subnet.cidrBlock)
  ),
  vpcDataSubCidrs: vpc.isolatedSubnets.then((a) =>
    a.map((s) => s.subnet.cidrBlock)
  ),
  usEast1aPubSubnet: ue1aPubSub,
};
m
so index 0 is always a, 1 is b, and so on. (I know that’s a horrible answer 🤣 )
This is the horrible solution we've used so far, but our use cases have now required a more complex representation of the VPC. That looks great, I'll take a note and play around with it after I close out some other projects/tasks. It would be great to have something like this in the awsx package already.