sparse-intern-71089
11/28/2023, 9:49 AMcuddly-computer-18851
11/28/2023, 9:56 AMstrong-vr-90029
11/28/2023, 9:58 AMstrong-vr-90029
11/28/2023, 9:58 AMstrong-vr-90029
11/28/2023, 9:58 AMcuddly-computer-18851
11/28/2023, 10:00 AMdry-keyboard-94795
11/28/2023, 10:05 AMget
functions for this doesn't work well. Consider that the resource doesn't exist, the stack will then create the resource.
On subsequent runs, the get
will find the resource, which will result in the resource getting deleted as you're fetching with get
instead of with the standard resource object.
A common strategy is to use multiple projects if you're in a situation where mulitple stacks depend on a common resource, then use stack references to pass the id around:
https://www.pulumi.com/learn/building-with-pulumi/stack-references/cuddly-computer-18851
11/28/2023, 10:08 AMimport
IDs, personally I'd consider it an anti-pattern unless you have some specific import migration task you're trying to accomplishstrong-vr-90029
11/28/2023, 10:20 AMdry-keyboard-94795
11/28/2023, 10:24 AMimport
to adopt an already existing resource; or stack references where you have common resources across multiple stacksstrong-vr-90029
11/28/2023, 10:34 AMVPC ID: ${vpcIdVal}
);
console.log(Public Subnet IDs: ${publicSubnetIdsVal}
);
});dry-keyboard-94795
11/28/2023, 10:38 AM.apply
doesn't necessarily run until the end of the stack, so the values will likely not be set.
Most resources will accept Output
as parameters, so can use vpc.id
directlystrong-vr-90029
11/28/2023, 11:00 AMdry-keyboard-94795
11/28/2023, 11:35 AMconst vpcIdVal: Output<string> = vpc.id
Like thisdry-keyboard-94795
11/28/2023, 11:37 AMconst publicSubnetIds: Output<string[]> = vpc.apply(v => v.tags["publicSubnetIds"].split(","))
Then apply can be used to extract individual values as well, though I think there's a dedicated function for querying subnetIDs based on the vpc