Remove workspace includes from policy set reads #1080
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR speeds up policy set refreshes by removing the
include=workspaces
query param from those calls. It takes extra time to serialize the workspace record on the backend and it doesn't seem like any workspace data besides the id is necessary to managetfe_workspace_policy_set
resources in the provider. This is especially noticeable for a policy set attached to a large number of workspaces.Note that we do still need need the workspace records here, so we can find a workspace associated with the policy set by name:
terraform-provider-tfe/internal/provider/resource_tfe_workspace_policy_set.go
Line 139 in ac43481
Remember to:
Testing plan
Example: creating some new workspaces and attaching them to an existing policy set:
This config can take a very long time to run, depending on how many workspaces this policy set is already attached to. On my local environment with
my-policy-set
already attached to 1000 workspaces, it took about 1m15s to apply the above config due to theinclude=workspaces
query parameter when refreshing a policy set. Without theinclude=workspaces
query parameter it takes about 10s.Output from acceptance tests
Please run applicable acceptance tests locally and include the output here. See testing.md to learn how to run acceptance tests.
If you are an external contributor, your contribution(s) will first be reviewed before running them against the project's CI pipeline.