careful-beard-19872
08/09/2021, 5:19 PMmillions-furniture-75402
08/09/2021, 6:00 PMconst 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));
careful-beard-19872
08/09/2021, 6:45 PMimport * 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,
};
millions-furniture-75402
08/10/2021, 1:13 PMso 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.