terraform-provider-tfe
terraform-provider-tfe copied to clipboard
Flipping `r.tfe_workspace` from agent to default (remote) exec mode fails to plan
Terraform Cloud/Enterprise version
- Terraform Cloud
Terraform version
Terraform v1.2.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/azuread v2.22.0
+ provider registry.terraform.io/hashicorp/tfe v0.31.0
+ provider registry.terraform.io/hashicorp/vault v3.6.0
+ provider registry.terraform.io/microsoft/azuredevops v0.2.1
Terraform Configuration Files
The resource definition before the change.
Note the use of an agent which we had to use temporarily to workaround an issue in v1.2.6 of the TFC agent.
resource "tfe_workspace" "tenantConfiguration" {
name = "tenantConfiguration-${var.environment}"
organization = local.tfc_orgname[var.environment]
description = null
global_remote_state = false
tag_names = null
working_directory = null
structured_run_output_enabled = false
# temp agent config
execution_mode = "agent"
agent_pool_id = data.tfe_agent_pool.temp.id
}
Once the issue was resolved, the above resource definition was returned to its normal configuration:
resource "tfe_workspace" "tenantConfiguration" {
name = "tenantConfiguration-${var.environment}"
organization = local.tfc_orgname[var.environment]
description = null
global_remote_state = false
tag_names = null
working_directory = null
structured_run_output_enabled = false
}
Debug Output
- none provided, its a simple enough repro.
Expected Behavior
The TFC plan should have detected the change and completed the plan.
Actual Behavior
The TFC plan failed with the following output:
│ Error: agent_pool_id must be provided when execution_mode is 'agent'
│
│ with tfe_workspace.tenantConfiguration,
│ on tenants_workspace.tf line 57, in resource "tfe_workspace" "tenantConfiguration":
│ 57: resource "tfe_workspace" "tenantConfiguration" {
Additional Context
To provide a little context for the order of events here:
- We hit an issue in the v1.2.6 release of the TFC agent which caused a TFC Workspace plan to fail
- Support asked us to switch the Workspace over to use `execution_mode = "agent" and pin the agent to the v1.2.5 release.
- Following this change the TFC Workspace was able to execute plans successfully.
- Support got back to us with a root-cause and fix for our issue
- We reverted the
tfe_workspace
resource to its normal default execution_mode by removing the line from the resource attributes. - During the plan for that change the above error was generated
- I then updated the
tfe_workspace
resource to specifically include theexecution_mode = "remote"
attribute. - The plan and apply was then successful.
Thanks for reporting! I have created a ticket in our team's backlog to take a closer look at this issue. @ausfestivus
We also got bitten by this one, with a different trigger. In our case, someone had manually flipped a workspace from remote to agent execution mode through the UI in order to test something. The resulting refreshed resource state caused our TFE configuration pipeline to break until the change was identified and manually reverted through the UI.
This was fixed in release v0.37.0 but we forgot to close this issue.