https://pulumi.com logo
#typescript
Title
# typescript
w

worried-painting-67291

08/24/2020, 5:43 PM
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

hundreds-musician-51496

08/24/2020, 6:12 PM
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

worried-painting-67291

08/24/2020, 7:10 PM
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

green-school-95910

08/24/2020, 7:59 PM
In this case you should have a stack with the shared resources and use StackReference to access them from other stacks
h

hundreds-musician-51496

08/24/2020, 8:31 PM
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

worried-painting-67291

08/24/2020, 10:18 PM
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..