Introduction
Using the TFE provider to create a workspace with the tags argument results in 0 Tags added in Terraform Enterprise.
Prerequisites
- TFE v202503-1
- tfe_workspace resource
- use the tags argument
Problem
There are 2 problems that arise:
- Creating a workspace with tags using the tfe_workspace resource from the TFE provider results in the tags appearing empty in the TFE UI.
Sample code:
resource "tfe_workspace" "test" { name = "tfe-provider-workspace-tag-2" organization = "test" tags = { NAME = "test" linkingId = "DANI0015277" owningTransactionCycleId = "18" primaryOwner = "firstname lastname" } }
User Interface screenshot of the actual problem:
2. On a subsequent run of terraform apply
, Terraform wants to create the tags again:
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 of adding key-value tags to Terraform Enterprise workspaces is not yet available on TFE v202503-1.
Solution:
- Upgrade your Terraform Enterprise application to v202504-1 where is possible to use a key-value tagging scheme for Terraform Enterprise workspaces and projects.
Outcome
Once the application is upgraded, the tags are added on the Terraform workspaces in the UI:
-
The tag image appears from the list of workspaces:
- On the workspace itself, it is possible to see the tags in details now:
- When doing another subsequent run like
terraform apply
, Terraform doesn't make any changes anymore:
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.
Additional Information
- TFE Provider Documentation
- tfe_workspace resource along with the tags argument
- TFE Features for v202504-1