I keep running into situations where I want to cre...
# general
I keep running into situations where I want to create resources in
. For example, I create a vpc
Copy code
const vpc = new awsx.ec2.Vpc(...)
then I want to add a route to a transit gateway to each route table
Copy code
const onPremIps = ...
const transitGatewayIps = ...
const routeTables = aws.ec2.getRouteTablesOutput({ vpcId: vpc.vpcId })
routeTables.apply((rts) =>
  rts.ids.forEach((id) => {
    new aws.ec2.Route(`${id}-onprem-route`, {
      routeTableId: id,
      destinationCidrBlock: onPremIps,
Is there some other way I’m supposed to be doing this kind of thing?
To generalize, I guess what I’m looking for is a way to treat
to get values.
I had a similar issue and asked this question https://pulumi-community.slack.com/archives/C019YSXN04B/p1674121180254749. In general Pulumi encourages not to create resources in apply if possible because it may cause issues on diffs. However as can be seen from the example that I link to in the comment to my post they do so themselves when necessary, because sometimes, especially in networking resources depend on each other, so doing it in the apply is necessary. Hope this helps.