I have a scenario, where a couple of teammates are trying to create a resource in AWS- one of them has created it via the aws console. What happens when another developer tries to create the same resource with the same name?
If you are using Terraform you really should use other tools to manage the same resources.
If someone creates a resource outside of Terraform and at the same time you add code to manage the resource and run
terraform apply what happens depends on the resource. If the name has to be unique then the run will fail with an error (you can adopt the existing resource to be managed by Terraform using
terraform import). If the resource doesn’t have a uniqueness requirement then Terraform will make a new one, so you end up with the Terraform managed version and the manually created one (which Terraform knows nothing about).
@stuart-c: Thank you so much for replying. Please pardon my ignorance. If uniqueness is a requirement, why will terraform throw an error( Like you mentioned earlier, Terraform is not aware of the manually created resource anyway right)? Could you please elaborate a bit more or point me to resources that will help clarify?
Because if there can only be one resource called “bob” which was created manually (and not known to Terraform) the next time you run
terraform apply it will try to create the resource and fail with the error “the resource bob already exists”.