Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour: destroying resource tfe_workspace_run triggers destroy run of workspace’s managed resources #1535

Open
KatjaLeberwurst opened this issue Dec 2, 2024 · 0 comments
Labels

Comments

@KatjaLeberwurst
Copy link

KatjaLeberwurst commented Dec 2, 2024

Terraform Enterprise version

v202410-1

Terraform version

Terraform Version: v1.7.4
tfe-Provider Version: 0.58.0

Terraform Configuration Files

terraform {
  required_version = ">= 0.12"

  cloud {

    hostname     = "hostname"
    organization = "organization"

    workspaces {
      name = "managment-workspace"
    }
  }
  required_providers {
    tfe = {
      version = "0.58.0"
      source = "hashicorp/tfe"
    }
  }
}

provider "tfe" {
  hostname = "hostname"
}

resource "tfe_workspace" "workspace" {
  name                  = "workspacename"
  organization          = "organization"
  speculative_enabled   = true
  file_triggers_enabled = true
  auto_apply            = true
  force_delete          = false
}

resource "tfe_workspace_settings" "workspace_settings" {
  workspace_id   = tfe_workspace.workspace.id
  execution_mode = "remote"
}

resource "tfe_workspace_run" "ws_run" {
  workspace_id = tfe_workspace.workspace.id

  destroy {
    manual_confirm = false
    retry          = false
    wait_for_run   = true
  }
}

Debug Output

...

Expected Behavior

In the past, we have included the resource tfe_workspace_run in our Terraform configuration to ensure that the corresponding workspace is only deleted when the resources managed in it have already been destroyed. This also worked. 
However, as we no longer need this tfe_workspace_run resource, we have removed it from our Terraform configuration and executed a Terraform plan. The plan indicated that only this resource would be destroyed, which is exactly what we would have expected. For this reason, we triggered Terraform Apply.

Actual Behavior

However, terraform apply resulted in all resources managed by the corresponding workspace being destroyed and then the tfe_workspace_run resource. Is the behavior a bug or was it to be expected that all resources managed by the workspace were destroyed?

Additional Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant