|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "gitlab_group_protected_environment Resource - terraform-provider-gitlab" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + The gitlab_group_protected_environment resource allows to manage the lifecycle of a protected environment in a group. |
| 7 | + ~> In order to use a userid in the deploy_access_levels configuration, |
| 8 | + you need to make sure that users have access to the group with Maintainer role or higher. |
| 9 | + In order to use a groupid in the deploy_access_levels configuration, |
| 10 | + the group_id must be a sub-group under the given group. |
| 11 | + Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/group_protected_environments.html |
| 12 | +--- |
| 13 | + |
| 14 | +# gitlab_group_protected_environment (Resource) |
| 15 | + |
| 16 | +The `gitlab_group_protected_environment` resource allows to manage the lifecycle of a protected environment in a group. |
| 17 | + |
| 18 | +~> In order to use a user_id in the `deploy_access_levels` configuration, |
| 19 | + you need to make sure that users have access to the group with Maintainer role or higher. |
| 20 | + In order to use a group_id in the `deploy_access_levels` configuration, |
| 21 | + the group_id must be a sub-group under the given group. |
| 22 | + |
| 23 | +**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/group_protected_environments.html) |
| 24 | + |
| 25 | +## Example Usage |
| 26 | + |
| 27 | +```terraform |
| 28 | +# Example with deployment access level |
| 29 | +resource "gitlab_group_protected_environment" "example_with_access_level" { |
| 30 | + group = 12345 |
| 31 | + required_approval_count = 1 |
| 32 | + environment = "production" |
| 33 | +
|
| 34 | + deploy_access_levels = [ |
| 35 | + { |
| 36 | + access_level = "developer" |
| 37 | + } |
| 38 | + ] |
| 39 | +} |
| 40 | +
|
| 41 | +# Example with group-based deployment level |
| 42 | +resource "gitlab_group_protected_environment" "example_with_group" { |
| 43 | + group = 12345 |
| 44 | + environment = "staging" |
| 45 | +
|
| 46 | + deploy_access_levels = [ |
| 47 | + { |
| 48 | + group_id = 456 |
| 49 | + } |
| 50 | + ] |
| 51 | +} |
| 52 | +
|
| 53 | +# Example with user-based deployment level |
| 54 | +resource "gitlab_group_protected_environment" "example_with_user" { |
| 55 | + group = 12345 |
| 56 | + environment = "other" |
| 57 | +
|
| 58 | + deploy_access_levels = [ |
| 59 | + { |
| 60 | + user_id = 789 |
| 61 | + } |
| 62 | + ] |
| 63 | +} |
| 64 | +
|
| 65 | +# Example with multiple deployment access levels |
| 66 | +resource "gitlab_group_protected_environment" "example_with_multiple" { |
| 67 | + group = 12345 |
| 68 | + required_approval_count = 2 |
| 69 | + environment = "development" |
| 70 | +
|
| 71 | + deploy_access_levels = [ |
| 72 | + { |
| 73 | + access_level = "developer" |
| 74 | + }, |
| 75 | + { |
| 76 | + group_id = 456 |
| 77 | + }, |
| 78 | + { |
| 79 | + user_id = 789 |
| 80 | + } |
| 81 | + ] |
| 82 | +} |
| 83 | +
|
| 84 | +# Example with access-level based approval rules |
| 85 | +resource "gitlab_group_protected_environment" "example_with_multiple" { |
| 86 | + group = 12345 |
| 87 | + required_approval_count = 2 |
| 88 | + environment = "testing" |
| 89 | +
|
| 90 | + deploy_access_levels = [ |
| 91 | + { |
| 92 | + access_level = "developer" |
| 93 | + } |
| 94 | + ] |
| 95 | +
|
| 96 | + approval_rules = [ |
| 97 | + { |
| 98 | + access_level = "developer" |
| 99 | + } |
| 100 | + ] |
| 101 | +} |
| 102 | +
|
| 103 | +# Example with multiple approval rules, using access level, user, and group |
| 104 | +resource "gitlab_group_protected_environment" "example_with_multiple" { |
| 105 | + group = 12345 |
| 106 | + required_approval_count = 2 |
| 107 | + environment = "production" |
| 108 | +
|
| 109 | + deploy_access_levels = [ |
| 110 | + { |
| 111 | + access_level = "developer" |
| 112 | + } |
| 113 | + ] |
| 114 | +
|
| 115 | + approval_rules = [ |
| 116 | + { |
| 117 | + user_id = 789 |
| 118 | + }, |
| 119 | + { |
| 120 | + access_level = "developer" |
| 121 | + }, |
| 122 | + { |
| 123 | + group_id = 456 |
| 124 | + } |
| 125 | + ] |
| 126 | +} |
| 127 | +``` |
| 128 | + |
| 129 | +<!-- schema generated by tfplugindocs --> |
| 130 | +## Schema |
| 131 | + |
| 132 | +### Required |
| 133 | + |
| 134 | +- `deploy_access_levels` (Attributes Set) Array of access levels allowed to deploy, with each described by a hash. (see [below for nested schema](#nestedatt--deploy_access_levels)) |
| 135 | +- `environment` (String) The deployment tier of the environment. Valid values are `production`, `staging`, `testing`, `development`, `other`. |
| 136 | +- `group` (String) The ID or full path of the group which the protected environment is created against. |
| 137 | + |
| 138 | +### Optional |
| 139 | + |
| 140 | +- `approval_rules` (Attributes Set) Array of approval rules to deploy, with each described by a hash. (see [below for nested schema](#nestedatt--approval_rules)) |
| 141 | +- `required_approval_count` (Number) The number of approvals required to deploy to this environment. |
| 142 | + |
| 143 | +### Read-Only |
| 144 | + |
| 145 | +- `id` (String) The ID of this Terraform resource. In the format of `<group>:<environment-name>`. |
| 146 | + |
| 147 | +<a id="nestedatt--deploy_access_levels"></a> |
| 148 | +### Nested Schema for `deploy_access_levels` |
| 149 | + |
| 150 | +Optional: |
| 151 | + |
| 152 | +- `access_level` (String) Levels of access required to deploy to this protected environment. Valid values are `developer`, `maintainer`. |
| 153 | +- `group_id` (Number) The ID of the group allowed to deploy to this protected environment. The group must be a sub-group under the given group. |
| 154 | +- `user_id` (Number) The ID of the user allowed to deploy to this protected environment. The user must be a member of the group with Maintainer role or higher. |
| 155 | + |
| 156 | +Read-Only: |
| 157 | + |
| 158 | +- `access_level_description` (String) Readable description of level of access. |
| 159 | +- `id` (Number) The unique ID of the Deploy Access Level object. |
| 160 | + |
| 161 | + |
| 162 | +<a id="nestedatt--approval_rules"></a> |
| 163 | +### Nested Schema for `approval_rules` |
| 164 | + |
| 165 | +Optional: |
| 166 | + |
| 167 | +- `access_level` (String) Levels of access allowed to approve a deployment to this protected environment. Valid values are `developer`, `maintainer`. |
| 168 | +- `group_id` (Number) The ID of the group allowed to approve a deployment to this protected environment. TThe group must be a sub-group under the given group. This is mutually exclusive with user_id. |
| 169 | +- `required_approvals` (Number) The number of approval required to allow deployment to this protected environment. This is mutually exclusive with user_id. |
| 170 | +- `user_id` (Number) The ID of the user allowed to approve a deployment to this protected environment. The user must be a member of the group with Maintainer role or higher. This is mutually exclusive with group_id and required_approvals. |
| 171 | + |
| 172 | +Read-Only: |
| 173 | + |
| 174 | +- `access_level_description` (String) Readable description of level of access. |
| 175 | +- `id` (Number) The unique ID of the Approval Rules object. |
| 176 | + |
| 177 | +## Import |
| 178 | + |
| 179 | +Import is supported using the following syntax: |
| 180 | + |
| 181 | +```shell |
| 182 | +# GitLab group protected environments can be imported using an id made up of `groupId:environmentName`, e.g. |
| 183 | +terraform import gitlab_group_protected_environment.bar 123:production |
| 184 | +``` |
0 commit comments