Introduction
When using the TFE provider to create a workspace in Terraform Enterprise, you may find that tags defined in the configuration are not applied to the workspace.
Prerequisites
- Terraform Enterprise v202503-1 or lower
- The tfe_workspace resource with the
tagsargument
Problem
When you use the tfe_workspace resource to create a workspace with tags, the tags do not appear in the Terraform Enterprise UI. Additionally, a subsequent terraform apply run generates a plan to add the tags again, indicating that Terraform state is out of sync with the workspace's actual configuration.
This is an example configuration.
resource "tfe_workspace" "test" {
name = "tfe-provider-workspace-tag-2"
organization = "test"
tags = {
NAME = "test"
linkingId = "EXAMPLE-12345"
owningTransactionCycleId = "18"
primaryOwner = "example-user"
}
}The Terraform Enterprise UI shows that no tags were added.
Running terraform apply again shows that Terraform will attempt to add the tags on every run.
$ terraform apply
tfe_workspace.test: Refreshing state... [id=ws-zn2Ywzn5Su9xsxjf]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# tfe_workspace.test will be updated in-place
~ resource "tfe_workspace" "test" {
id = "ws-zn2Ywzn5Su9xsxjf"
name = "tfe-provider-workspace-tag-2"
~ tags = {
+ "NAME" = "test"
+ "linkingId" = "DANI0015277"
+ "owningTransactionCycleId" = "18"
+ "primaryOwner" = "firstname lastname"
}
# (31 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.Cause
The feature to add key-value tags to Terraform Enterprise workspaces is not available in Terraform Enterprise version v202503-1.
Solution
To resolve this issue, upgrade your Terraform Enterprise application to version v202504-1 or later. This version introduces support for the key-value tagging scheme for workspaces and projects.
Outcome
After you upgrade the application, the tags are correctly applied to Terraform workspaces.
The tag icon appears next to the workspace in the UI list.
Within the workspace settings, you can view the tag details.
Subsequent terraform apply runs will report no changes.
$ terraform apply tfe_workspace.test: Refreshing state... [id=ws-iwj1pw32Sab366ZA] No changes. Your infrastructure matches the configuration. Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed. Apply complete! Resources: 0 added, 0 changed, 0 destroyed.