Skip to content

removed blocks are not supported #340

Description

@iwahbe

Divergence

A removed block that forgets a resource from state without destroying it is accepted and applied by OpenTofu, but pulumi-hcl rejects the program:

error: an unhandled error occurred: .../main.tf:4,1-8: Unsupported block type; Blocks of type "removed" are not expected here. Did you mean "moved"?

OpenTofu applies the same program cleanly and reports:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed, 1 forgotten.

removed blocks are a stable state-refactoring construct (since 1.7); the parser handles moved and import but has no removed case, and the root-body HCL schema rejects the block before parsing.

Reproducer

Two-stage program (no providers; terraform_data is a builtin on both paths).

Stage 0 — create:

resource "terraform_data" "keep" {
  input = "hello"
}

output "value" {
  value = terraform_data.keep.output
}

Stage 1 — drop the resource from configuration and forget it:

removed {
  from = terraform_data.keep
  lifecycle {
    destroy = false
  }
}

output "value" {
  value = "forgotten"
}

tofu apply of stage 1 succeeds with 1 forgotten and leaves the object untouched; pulumi up fails with the unsupported-block error above.

A tfcompat test for this exists as TestL2RemovedForget (two StageApply stages over numbered fixture dirs l2_removed_forget/0 and 1), verified failing on master at the stage-1 pulumi up.

A lone removed block targeting nothing in state is also a valid no-op in OpenTofu and fails identically, if a single-stage reproducer is preferred.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions