I have a problem where I want to create new subnet...
# typescript
I have a problem where I want to create new subnets but some already exist, and I need them to be deleted before the create happens otherwise they will conflict. I found deleteBeforeReplace but don’t think that solves my issue. Is there any way to make delete actions happen on a resource before any creates happen?
Are the subnets created automatically by your cloud provider, or implicitly by a sophisticated resource like
? Or are they simply already existing and unmanaged?
You have a few options, but they all sidestep Pulumi, because Pulumi cannot manage (== delete) unmanaged resources, and it cannot delete some things before it creates other things.
they are managed by pulumi, aws.ec2.Subnets specifically.
I have a config that is used to input what subnets we want to create.
If I remove all entries from that config and replace them with new ones, instead of destroying the old ones and then creating, it creates first
That is intentional, to help with zero-downtime updates. The Pulumi docs about autonaming covers the topic: https://www.pulumi.com/docs/intro/concepts/resources/#autonaming
To manage this in your case, if it is once-off, you could make the changes and comment the relevant code out, then `up`: this will delete the old vresions; then put the code back and
Another option is to rework into separate projects or stacks, and use
Finally, you could ensure that the Pulumi name of the resources doesn't change. Pulumi will attempt to update rather than destroy/create.
alright, thank you!