# When respective code is not there , how to prevent destroy

**URL:** <https://discuss.hashicorp.com/t/when-respective-code-is-not-there-how-to-prevent-destroy/44390>\
**Category:** Terraform\
**Created:** [September 16, 2022, 9:18am UTC](https://discuss.hashicorp.com/t/when-respective-code-is-not-there-how-to-prevent-destroy/44390 "2022-09-16T09:18:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sk8228402](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/sk8228402/32/25064_2.png) [@sk8228402](https://discuss.hashicorp.com/u/sk8228402)\
**Post date:** [September 16, 2022, 9:18am UTC](https://discuss.hashicorp.com/t/when-respective-code-is-not-there-how-to-prevent-destroy/44390/1 "2022-09-16T09:18:42Z")

</div>

I have created resource group in azure using terraform, after creating I have removed that code from terraform  
and wrote the code to create another resource group but now while creating this resource group why it is going destroy? which while I was implementing terraform apply.

why it is getting removed when it is available in state file?  
and also what need to be done to prevent deletion when respective code is not present?

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [September 16, 2022, 8:13pm UTC](https://discuss.hashicorp.com/t/when-respective-code-is-not-there-how-to-prevent-destroy/44390/2 "2022-09-16T20:13:23Z")

</div>

Hi @sk8228402,

Your configuration should describe the desired state for your infrastructure. If you remove a resource block then you are telling Terraform that the corresponding object should be destroyed.

If you don’t intend to destroy the object then you should leave it in the configuration.
