-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get resource_count information for configured tfe_workspace resources #448
Comments
That idea appears to work. With this change:
And this added to my Terraform configuration:
Then...
So I expect adding something similar for the other attributes available in the data source would work similarly. |
Issue addressed via #682 |
Awesome stuff! That'll definitely be useful, though my use case in particular is actually solved by a much more useful feature we recently added: Safe Delete! |
Use-cases
When reading a workspace with the
tfe_workspace
data source, it is possible to identify how many resources that workspace is currently managing.See https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/data-sources/workspace#resource_count
However, when we create the workspace with the
tfe_workspace
resource, we do not get that information back in the attributes.While it is already possible to write a sentinel policy that prevents deletion of workspaces:
hashicorp/terraform-sentinel-policies#3
Not having the
resource_count
attribute available in thetfe_workspace
resource prevents us from writing a more complex sentinel policy, along the lines of "do not allow deletion of a workspace, unless it currently does not manage any resources"Proposal
As part of
dataSourceTFEWorkspaceRead
we have:https://github.com/hashicorp/terraform-provider-tfe/blob/main/tfe/data_source_workspace.go#L179
We could add that to the resource schema as
Computed: true
, and include that samed.Set
inresourceTFEWorkspaceRead
to make that information available:https://github.com/hashicorp/terraform-provider-tfe/blob/main/tfe/resource_tfe_workspace.go#L332
Other attributes read by the data source could be added too, if they would be useful, though
resource_count
is the one I have an immediate use-case for.If this seems like a sensible approach, I can raise a PR to implement this.
The text was updated successfully, but these errors were encountered: