Skip to content

New Code Action: Remove a block from state (generate removed block) #1568

Open
@radeksimko

Description

@radeksimko

Background

While working with existing Terraform configuration that has already been deployed, users may sometime wish to "dis-own" a particular resource, or a module, i.e. prevent Terraform from managing it but not destroy it in the process of doing so.

Previously this was done via terraform state rm and Terraform v1.7 comes with a removed {} block which provides equivalent functionality via configuration.

Users may begin with

resource "aws_instance" "to-disown" {
  // ...
}

and end up with

removed {
  from = aws_instance.to-disown

  lifecycle {
    destroy = false
  }
}

Proposal

  • Provide code actions to remove stateful blocks, i.e. replace them with removed {} block
    • Remove resource
    • Remove data
    • Remove module

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions