I think I remember seeing this a couple months ago...
# typescript
w
I think I remember seeing this a couple months ago, but I can't find it now: Is there an example of createIfNotExists for AWS resources? Specifically: I have multiple clusters in seperate VPCs.. The clusters share dynamo and RDS tables, though, so I need a way to createIfNotExists those resources.
h
If those resources are all in the same stack, you don't need a "create if not exists" because pulumi does that automatically (only creates the resources once).
w
when i run aws.dynamodb.Table( ...) it fails, though, because the resource already exists..
they are in a separate stack.
the stacks share a few resources..
g
In this case you should have a stack with the shared resources and use StackReference to access them from other stacks
h
I don't think pulumi handles inter-stack dependencies very well. Probably the safest approach is for your stack deployment to fail if the shared resources don't exist. The static
get
method on each resource will retrieve an existing resource (for example https://www.pulumi.com/docs/reference/pkg/aws/dynamodb/table/#look-up) and fail if that resource does not exist. A stack reference would help in that the stack managing the shared resources could output the RDS/Dynamo ARNs, which your downstream stack can consume and use as arguments for the
get
method.
w
Gotcha.. so using the shared Resources between stacks is the best approach.. that makes sense.. that pretty much means all I need to do is keep track of which stack "owns" the resources.. which is not a big deal..