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?
I don’t think that can be done. It isn’t really how Terraform is intended to be used - Terraform manages all the resources listed in the code and doesn’t allow other systems/processes to manage conflicting resources (e.g. things with the same name). You need to ensure that there is a clear boundary between the things managed by Terraform and anything else, including making sure naming (if it is required to be unique) doesn’t clash. You can then interact with the non-Terraform managed resources if needed by using data sources.