Repository navigation
fix: Create protected environments after project group shares - #17
Merged
Merged
Conversation
GitLab accepts a group in an environment's deploy access levels or approval rules only when the group is shared on the project itself, and drops it otherwise. When an apply shared a group and protected an environment for it at once, the environment POST could run first and fail with "Deploy access levels is too short (minimum is 1 character)". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wiseelf
self-requested a review
October 29, 2026 00:30
|
This PR is included in version 2.3.1 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
GitLab accepts a group in a protected environment's deploy access levels (and approval rules) only when that group is shared on the project itself. Access inherited through a parent group doesn't count. Otherwise GitLab drops the group without an error.
gitlab_project_protected_environmenthad no dependency ongitlab_project_share_group, so when an apply shared a group and protected an environment for it at once, Terraform ran both in parallel.That's what happened in a real apply: the share for the deploy group was created after the environment POST had been sent. GitLab discarded the not-yet-shared group, which left the list empty, and rejected the request:
The plan succeeded, and re-planning and applying again after the share existed created the environment. So this is purely an ordering problem.
What
gitlab_project_protected_environment.thisgetsdepends_on = [gitlab_project_share_group.this], so project shares are created before protected environments, and the environment is destroyed before the share.terraform validateandterraform test(12 passed) are green. A mock provider can't reproduce the API-side ordering, so no test was added.🤖 Generated with Claude Code