mongodb/terraform-provider-mongodbatlas

[Bug]: Unexpected behaviour: destroying resource tfe_workspace_run triggers destroy run of workspace’s managed resources

Closed this issue · 3 comments

Is there an existing issue for this?

  • I have searched the existing issues

Provider Version

tfe: Version 0.58.0

Terraform Version

v1.7.4

Terraform Edition

Terraform Enterprise

Current 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. However, this 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?

Terraform configuration to reproduce the issue

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 = var.tfe_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
  }
}

Steps To Reproduce

  1. Remove resource tfe_workspace_run from terraform configuration
  2. Execute terraform plan
  3. Execute terraform apply

Logs

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

  • Terraform configuration file used to reproduce the issue
  • Terraform log files from the run where the issue occurred
  • Terraform Atlas provider version used to reproduce the issue
  • Terraform version used to reproduce the issue
  • Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

The ticket CLOUDP-287415 was created for internal tracking.

Hi @KatjaLeberwurst
I think you have opened the issue in the wrong repository. Please re-open if this is not the case 😅

Hi @EspenAlbert

You're right!
Thank you for bringing this to my attention. 😅