{"id":72032,"date":"2025-05-29T15:04:47","date_gmt":"2025-05-29T09:34:47","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=72032"},"modified":"2025-05-29T22:38:47","modified_gmt":"2025-05-29T17:08:47","slug":"modern-terraform-practices-removing-resources-safely-from-state","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/modern-terraform-practices-removing-resources-safely-from-state\/","title":{"rendered":"Modern Terraform Practices: Removing Resources Safely from State"},"content":{"rendered":"<h2><span style=\"text-decoration: underline;\"><strong>Introduction and Usecase<\/strong><\/span><\/h2>\n<p>There are times when we want Terraform to stop managing a resource, but don\u2019t want to delete it from the infrastructure.<\/p>\n<p>In this brief blog, I&#8217;m going to discuss removing resources from Terraform configuration files while keeping them in real infrastructure. But why would you want to do this in the first place? Let\u2019s see some possible reasons:<\/p>\n<ol>\n<li>One possible reason is that you are handing over the resource to another team that prefers to manage it differently.<\/li>\n<li>There could be a maintenance window planned, and you want to remove certain resources from being managed by Terraform during that time frame.<\/li>\n<li>Or maybe you&#8217;re splitting Terraform modules and want to restructure your configuration files.<br \/>\nIn this blog, I\u2019ll show different ways to remove a resource from Terraform without deleting it from your AWS cloud environment, using a simple EC2 instance as an example.<\/li>\n<\/ol>\n<div id=\"attachment_72028\" style=\"width: 754px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72028\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-72028 size-full\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-1.png\" alt=\"Removing Resources from Terraform Management\" width=\"744\" height=\"588\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-1.png 744w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-1-300x237.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-1-624x493.png 624w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><p id=\"caption-attachment-72028\" class=\"wp-caption-text\">Removing Resources from Terraform Management<\/p><\/div>\n<p>There are two ways to go about it. The first is the quick way, and the second is to leave a trace in your configuration file so that other people know you removed the resource. Let\u2019s explore both ways and see how they work.<\/p>\n<h2><span style=\"text-decoration: underline;\"><strong>Setup<\/strong><\/span><\/h2>\n<p>Let\u2019s say you already have a configuration like this:<\/p>\n<pre>resource \"aws_instance\" \"web\" {\r\n\u00a0 ami \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 = \"ami-04999cd8f2624f834\"\r\n\u00a0 instance_type = \"t2.micro\"\r\n\u00a0 tags = {\r\n\u00a0 \u00a0 Name = \"my-ec2-instance\"\r\n\u00a0 }\r\n}<\/pre>\n<p>You can check what Terraform is managing with:<\/p>\n<pre>terraform state list<\/pre>\n<div id=\"attachment_72029\" style=\"width: 1009px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72029\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-72029 size-full\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list.png\" alt=\"terraform state list\" width=\"999\" height=\"100\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list.png 999w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-300x30.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-768x77.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-624x62.png 624w\" sizes=\"(max-width: 999px) 100vw, 999px\" \/><p id=\"caption-attachment-72029\" class=\"wp-caption-text\">terraform state list<\/p><\/div>\n<h2><span style=\"text-decoration: underline;\"><strong>Possible Solutions<\/strong><\/span><\/h2>\n<h3><span style=\"text-decoration: underline;\"><strong>Solution 1: Using terraform rm (Traditional Way)<\/strong><\/span><\/h3>\n<p>So with our first approach, what I will do is run terraform state rm and specify the resource that I want to remove. Once I click Enter, my EC2 instance has now been removed from the state.<\/p>\n<div id=\"attachment_72030\" style=\"width: 1227px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72030\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72030\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm.png\" alt=\"terraform state rm\" width=\"1217\" height=\"133\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm.png 1217w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm-300x33.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm-1024x112.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm-768x84.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_rm-624x68.png 624w\" sizes=\"(max-width: 1217px) 100vw, 1217px\" \/><p id=\"caption-attachment-72030\" class=\"wp-caption-text\">terraform state rm<\/p><\/div>\n<p>So if I do terraform state list now, Terraform is no longer managing my resource, and it has been removed from the state file.<\/p>\n<div id=\"attachment_72031\" style=\"width: 1227px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72031\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72031\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list.png\" alt=\"terraform state list\" width=\"1217\" height=\"133\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list.png 1217w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-300x33.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-1024x112.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-768x84.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-624x68.png 624w\" sizes=\"(max-width: 1217px) 100vw, 1217px\" \/><p id=\"caption-attachment-72031\" class=\"wp-caption-text\">terraform state list<\/p><\/div>\n<p>If I do a terraform plan now, Terraform does not have it in the state file anymore, so it would try to recreate the resource.<\/p>\n<div id=\"attachment_72033\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72033\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-72033 size-large\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-1024x680.png\" alt=\"Terraform Plan\" width=\"625\" height=\"415\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-1024x680.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-300x199.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-768x510.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-1536x1020.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan-624x415.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Terraform-Plan.png 1600w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-72033\" class=\"wp-caption-text\">Terraform Plan<\/p><\/div>\n<div id=\"attachment_72034\" style=\"width: 635px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72034\" decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-72034\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-1024x627.png\" alt=\"Terraform Plan\" width=\"625\" height=\"383\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-1024x627.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-300x184.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-768x470.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-1536x941.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3-624x382.png 624w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-3.png 1600w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><p id=\"caption-attachment-72034\" class=\"wp-caption-text\">Terraform Plan<\/p><\/div>\n<p>Since we are trying to remove it, we have removed it from the state file. The next step would be to remove it from the configuration file. I\u2019m going to comment this out so that Terraform doesn\u2019t read it anymore and create the resource again.<\/p>\n<div id=\"attachment_72035\" style=\"width: 1353px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72035\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72035\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4.png\" alt=\"Comment Code\" width=\"1343\" height=\"327\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4.png 1343w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4-300x73.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4-1024x249.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4-768x187.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-4-624x152.png 624w\" sizes=\"(max-width: 1343px) 100vw, 1343px\" \/><p id=\"caption-attachment-72035\" class=\"wp-caption-text\">Comment Code<\/p><\/div>\n<p>Okay, so now if I do terraform plan, it\u2019s been removed from my configuration. If I do a terraform plan now, we should not see any changes, and the resource has been removed.<\/p>\n<div id=\"attachment_72036\" style=\"width: 1591px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72036\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72036\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5.png\" alt=\"Terraform Plan\" width=\"1581\" height=\"201\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5.png 1581w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5-300x38.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5-1024x130.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5-768x98.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5-1536x195.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-5-624x79.png 624w\" sizes=\"(max-width: 1581px) 100vw, 1581px\" \/><p id=\"caption-attachment-72036\" class=\"wp-caption-text\">Terraform Plan<\/p><\/div>\n<p>This is an acceptable way of removing resources from the state file, but still keeping them in a real cloud environment \u2014 you removed it from the state and then removed it from the configuration. But, you know, nobody knows that you\u2019ve done it, and that\u2019s when the second way of doing this kind of stuff comes in. Let\u2019s explore how.<\/p>\n<h3><span style=\"text-decoration: underline;\"><strong>Solution 2: Terraform Removed Block<\/strong><\/span><\/h3>\n<p><em><span style=\"text-decoration: underline;\"><strong>Note: Terraform v1.7 or later is required to use the `removed` block.<\/strong><\/span><\/em><\/p>\n<p>Let\u2019s now look into the second approach \u2014 using the removed block, which is a more advanced and trackable way to remove resources from the Terraform state without destroying them in the real infrastructure.<\/p>\n<p>Before we do that, I want to have the resource created in my infrastructure. So what I will do is bring the config back and do a terraform apply, which will create my EC2 instance again.<\/p>\n<p>In the previous setup, I had removed it from the state file, but it was still sitting in my AWS console. So just make sure, if you\u2019re following along and destroying resources using Terraform, that you also remove them from the console if needed.<\/p>\n<p>For this one, I\u2019m just going to say \u201cyes\u201d here. This will create my EC2 instance.<\/p>\n<div id=\"attachment_72037\" style=\"width: 848px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72037\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-72037 size-full\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-6.png\" alt=\"Terraform Plan\" width=\"838\" height=\"355\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-6.png 838w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-6-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-6-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-6-624x264.png 624w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><p id=\"caption-attachment-72037\" class=\"wp-caption-text\">Terraform Plan<\/p><\/div>\n<p>Okay, so my EC2 instance has been created again, and it is part of the state now. If I just do terraform state list, this instance is now part of the state and part of the Terraform configuration.<\/p>\n<div id=\"attachment_72045\" style=\"width: 1009px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72045\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72045\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list.png\" alt=\"terraform state list\" width=\"999\" height=\"100\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list.png 999w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-300x30.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-768x77.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform_state_list-624x62.png 624w\" sizes=\"(max-width: 999px) 100vw, 999px\" \/><p id=\"caption-attachment-72045\" class=\"wp-caption-text\">terraform state list<\/p><\/div>\n<p>But just keep in mind one thing: we created a new EC2 instance. The one that we removed from the configuration file \u2014 that\u2019s the one you would have to remove from the console. Now we\u2019re going to look into the second way of removing it, which is using the terraform removed block, which was released in terraform v1.7. Read here: <a href=\"https:\/\/github.com\/hashicorp\/terraform\/blob\/v1.7\/CHANGELOG.md\">https:\/\/github.com\/hashicorp\/terraform\/blob\/v1.7\/CHANGELOG.md<\/a><\/p>\n<p>Remove or comment out the existing aws_instance resource and add this new removed block, where you specify the from and the resource that you are going to remove, and then you use the lifecycle block, which is required so that Terraform does not destroy your resource.<\/p>\n<div id=\"attachment_72046\" style=\"width: 561px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72046\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72046\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-8.png\" alt=\"Terraform Removed Block\" width=\"551\" height=\"497\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-8.png 551w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-8-300x271.png 300w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><p id=\"caption-attachment-72046\" class=\"wp-caption-text\">Terraform Removed Block<\/p><\/div>\n<p>This tells Terraform:<\/p>\n<pre>from = aws_instance.web: This is the resource being removed from the state.<\/pre>\n<pre>lifecycle { destroy = false }: Ensures Terraform doesn\u2019t attempt to destroy the actual resource in AWS, just forgets about it in state.<\/pre>\n<p>Once you have commented\u00a0 the resource and specified this new removed block, you can save your configuration, come back here, and just do terraform plan. This would tell you that some of the objects will no longer be managed by Terraform.<\/p>\n<div id=\"attachment_72050\" style=\"width: 1610px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72050\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72050\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9.png\" alt=\"Terraform Removed Block\" width=\"1600\" height=\"606\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9.png 1600w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9-300x114.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9-1024x388.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9-768x291.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9-1536x582.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-9-624x236.png 624w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><p id=\"caption-attachment-72050\" class=\"wp-caption-text\">Terraform Removed Block<\/p><\/div>\n<p>For that to take effect, we have to do a terraform apply. So my state file knows about this. As soon as I do terraform apply, I just have to confirm it, and once the apply is completed, my EC2 instance is no longer being managed by Terraform.<\/p>\n<div id=\"attachment_72052\" style=\"width: 1610px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72052\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72052\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10.png\" alt=\"Terraform Apply\" width=\"1600\" height=\"758\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10.png 1600w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10-300x142.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10-1024x485.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10-768x364.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10-1536x728.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/unnamed-10-624x296.png 624w\" sizes=\"(max-width: 1600px) 100vw, 1600px\" \/><p id=\"caption-attachment-72052\" class=\"wp-caption-text\">Terraform Apply<\/p><\/div>\n<p>If I go to my state list with terraform state list, that EC2 instance is no longer being managed by Terraform.<\/p>\n<div id=\"attachment_72031\" style=\"width: 1227px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72031\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-72031\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list.png\" alt=\"terraform state list\" width=\"1217\" height=\"133\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list.png 1217w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-300x33.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-1024x112.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-768x84.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/terraform-state-list-624x68.png 624w\" sizes=\"(max-width: 1217px) 100vw, 1217px\" \/><p id=\"caption-attachment-72031\" class=\"wp-caption-text\">terraform state list<\/p><\/div>\n<p>And with that, we\u2019ve safely removed a Terraform-managed resource from state without destroying it, using the proper, trackable removed block approach.<\/p>\n<h2><span style=\"text-decoration: underline;\"><strong>Comparison<\/strong><\/span><\/h2>\n<table style=\"border-collapse: collapse; width: 73.1551%; height: 216px;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\"><span style=\"text-decoration: underline; color: #008000;\"><strong>Feature<\/strong><\/span><\/td>\n<td style=\"width: 28.5914%; height: 24px;\"><span style=\"text-decoration: underline; color: #008000;\"><strong>terraform state rm<\/strong><\/span><\/td>\n<td style=\"width: 34.6851%; height: 24px;\"><span style=\"text-decoration: underline; color: #008000;\"><strong>Terraform removed Block (Terraform v1.7+)<\/strong><\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Purpose<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Removes a resource from the state file using the imperative command.<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Declaratively removes a resource from the state via code<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Configuration Visibility<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Hidden \u2013 nothing in the code shows the resource was removed<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Visible in the Terraform configuration \u2013 leaves a trace<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Version Control Friendly<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Not trackable in version control<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Yes, as part of .tf files<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Auditable \/ Collaborative<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">No<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Yes &#8211; visible and trackable by teams<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Required Terraform Version<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Works with all versions of Terraform<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Requires Terraform v1.7 or newer<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Safety of Execution<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Manual \u2013 error-prone if misused<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Safer \u2013 explicit and intentional with lifecycle block<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Automation Friendly<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Less automation-friendly (CLI-only)<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Easily works in CI\/CD pipelines<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 21.662%; height: 24px;\">Ideal for<\/td>\n<td style=\"width: 28.5914%; height: 24px;\">Quick, ad-hoc resource removal<\/td>\n<td style=\"width: 34.6851%; height: 24px;\">Structured, team-based workflows<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span style=\"text-decoration: underline;\"><strong>Conclusion<\/strong><\/span><\/h2>\n<p>With the introduction of the removed block in Terraform v1.7, the process of safely removing terraform managed resources without impacting live infrastructure has\u00a0 become more transparent, auditable,versioned and collaboration-friendly. This can be really helpful during code refactoring, team transitions or complex migrations.<\/p>\n<p>At <a href=\"https:\/\/www.tothenew.com\/\">TO THE NEW<\/a>, we specialize in solving real-world DevOps challenges, from state management to large-scale infrastructure transformations on AWS, Azure, GCP, and other cloud providers. Whether you&#8217;re modernizing Terraform practices or planning a zero-downtime migration, our certified AWS architects and DevOps engineers are here to ensure your cloud journey is efficient, reliable, and future-proof.<\/p>\n<div id=\"attachment_72027\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img aria-describedby=\"caption-attachment-72027\" decoding=\"async\" loading=\"lazy\" class=\"wp-image-72027\" src=\"https:\/\/www.tothenew.com\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection.png\" alt=\"To The New Devops Solutions\" width=\"700\" height=\"555\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection.png 924w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-300x238.png 300w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-768x608.png 768w, \/blog\/wp-ttn-blog\/uploads\/2025\/05\/Safely-Removing-Terraform-Managed-Resources-Without-Deletion-visual-selection-624x494.png 624w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><p id=\"caption-attachment-72027\" class=\"wp-caption-text\">To The New Devops Solutions<\/p><\/div>\n<p>Stay connected for more practical insights as we continue to simplify cloud operations and enable smarter infrastructure decisions.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction and Usecase There are times when we want Terraform to stop managing a resource, but don\u2019t want to delete it from the infrastructure. In this brief blog, I&#8217;m going to discuss removing resources from Terraform configuration files while keeping them in real infrastructure. But why would you want to do this in the first [&hellip;]<\/p>\n","protected":false},"author":1601,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":203},"categories":[2348],"tags":[248,7324,7325,6276,7322,1892,6961,7321,6544,6835,7323,6053,1585,7320,2987],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/72032"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1601"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=72032"}],"version-history":[{"count":5,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/72032\/revisions"}],"predecessor-version":[{"id":72410,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/72032\/revisions\/72410"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=72032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=72032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=72032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}