-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add ability to attach a workspace to an existing policy set #591
Conversation
Could you clarify the note in the PR description:
I don't think I understand the implication of what is being said here. 🤔 |
I have added a more detailed explanation. Take a look and let me know if it makes more sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I re-apply a config containing a tfe_policy_set and a tfe_workspace_policy_set, the workspace_ids field is updated in-place, even if it does not appear in config
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_policy_set.test2 will be updated in-place
~ resource "tfe_policy_set" "test2" {
id = "polset-qBcEd8WAtFcxTKo6"
name = "test-policy-set-2"
~ workspace_ids = [
- "ws-T2kxkEtyTGCdsKXX",
]
# (4 unchanged attributes hidden)
}
I think this can be fixed by adding Computed: true to this field.
You should also add documentation to this argument to say that the recommended way is to use the tfe_workspace_policy_set resource instead and those two cannot be used simultaneously. I think we did the same thing with tfe_variable_set?
} | ||
|
||
resource "tfe_policy_set" "test" { | ||
name = "Test Policy Set" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an invalid value for name-- can only include letters, numbers, -, and _
7c224b6
to
b634d7f
Compare
b634d7f
to
b38c264
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make fmtcheck
failed on this code, but that is curious because the linter passed. I think we should probably go ahead and add fmtcheck to the github action!
Everything else looks good
That's interesting, I just did a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the disparity is my local go version
Description
Currently the lifecycle of the tfe_policy_set requires that all tfe_workspace resources are created first and then assigned in one call to the tfe_policy_set during creation of the policy. For example:
Consider the case where
tfe_workspace
resources are spread across multiple repositories. Where each team or repo wants to be able to create & attach workspaces to existing policy sets. For example,team-security
is in charge of creating policies and own security-repo having:team-dev
wants to create its workspaces indev-repo
but attach it to existing policies above:User pain point: This leads to each repo re-creating the same policy unnecessarily.
This PR adds
tfe_workspace_policy_set
which allows workspaces to be attached to existing policy sets.Note:
Since workspaces can be added across multiple repos to the same policy set, this means the policy-set state can be altered by various configs(repos). Similar behaviour with
tfe_workspace_variable_set
Remember to:
Update the Change Log
Update the Documentation
Testing plan
External links
Include any links here that might be helpful for people reviewing your PR. If there are none, feel free to delete this section.
Output from acceptance tests
Please run applicable acceptance tests locally and include the output here. See TESTS.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.