Unable to create a run for tfe_workspace_run resource

Hi,

We’re currently encountering an issue while attempting to create a run for the tfe_workspace_run resource. Here’s the configuration we’re using:

resource "tfe_workspace" "tfeWorkspace" {
  for_each = var.tfe_map

  name           = each.value["workspacename"]
  organization   = tfe_organization.orgName.name
  structured_run_output_enabled = each.value["structured_run_output_enabled"]
}


resource "tfe_workspace_run" "ws_run_child" {
  workspace_id    = tfe_workspace.tfeWorkspace["s3-project"].id
  depends_on   = [tfe_workspace_run.ws_run_parent]

  apply {
    manual_confirm = true
  }
}

We encounter the following error message:

module.tfe_dev_module.tfe_workspace_run.ws_run_parent: Creating...
Error: error creating run for workspace ws-xxxxxx: resource not found

It appears that the tfe_workspace_run resource is unable to locate the specified workspace, resulting in the failure to create the run. It is intersting to note that despite the existence and active status of the workspaces with the error ID “ws-xxxxxx,” the problem persists.

module.tfe_dev_module.tfe_workspace.tfeWorkspace["s3-project"]: Refreshing state... [id=ws-xxxxxx]

We’re unsure if this is a problem with the tfe provider or if there’s something we missed in our configurations. Your insights and guidance would be greatly appreciated.

Thanks,

It sounds like a permissions problem to me - the identity executing this Terraform configuration presumably doesn’t have access to create runs in that workspace, I guess?

Thank you for the suggestion. We use an administrative account to create workspaces and run workflows, so permissions shouldn’t be the issue. Any additional suggestions or ideas would be highly appreciated.

@emans , I am getting the same issue, were you able to solve that ?

Hello @M-Eslam ,

I reached out to Terraform Cloud support regarding this matter, and their response indicated that tfe_workspace_run appears to be functioning as intended. They tested the example provided in this article and confirmed its proper functionality. While I didn’t proceed further with it due to my focus on testing other features within Terraform Cloud, I will certainly keep you updated once I re-evaluate it.

thanks,

Thank you for the reply @emans.
I found the issue for me. I was using an Organization token, which have access to create workspace but not to create plan or apply. When I changed that to use a user token, I didn’t get this error anymore.