Terraform with gcp [facing an issues with apply and destroy ] while destory and updating infra

terraform apply


terraform destroy

I updated few things but when I use terraform apply it throwing already exist when i use terraform destroy destroy completed but 0 resources deleted

Hi @rrr-kgf,

Based on what you shared here, Terraform seems to have behaved as I would have expected: creating this object failed, and so when you ran the destroy command there were no objects to destroy and therefore Terraform reported “no changes”.

Terraform will only plan to destroy objects that are under Terraform’s management. It seems that you have an existing object that was created outside of Terraform that conflicts with what you told Terraform it should manage, and so to make progress you will need to choose one of the following options:

  • Change your configuration so that the declared object doesn’t conflict with an object already existing in the remote system. In this case I think that means either choosing a different project that doesn’t already include this object or choosing a different object name so that both can exist together in the same project.
  • Tell Terraform that it should consider itself now the exclusive owner of this existing object, using the terraform import command. If you do this, you are effectively saying that this object will now be managed only by Terraform and never manually through the UI or API and never with any other Terraform-like software. Terraform will then treat the object as if it was created in Terraform, including potentially destroying the object if asked to.
  • Manually delete the conflicting object in the remote system outside of Terraform, and then run terraform apply to let Terraform create a replacement object that it will then manage.