Reputation: 1245
I want to be able to create a resource depending on if a resource with the same name exists or not. count can be used to conditionally create the resource but how do I check for the existence of a resource by name in terraform?
Upvotes: 1
Views: 1234
Reputation: 239000
ow do I check for the existence of a resource by name in terraform?
You can't, as there is no build in functionality in TF to check for pre-existing resources. But you can develop your own external data source to do that. Since its a fully custom data source, you can program it to check for the existence of your resources, and use that information later in your TF config files.
Upvotes: 2