|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "gitlab_project_protected_environment Resource - terraform-provider-gitlab" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + The gitlab_project_protected_environment resource allows to manage the lifecycle of a protected environment in a project. |
| 7 | + Upstream API: GitLab REST API docs https://docs.gitlab.com/ee/api/protected_environments.html |
| 8 | +--- |
| 9 | + |
| 10 | +# gitlab_project_protected_environment (Resource) |
| 11 | + |
| 12 | +The `gitlab_project_protected_environment` resource allows to manage the lifecycle of a protected environment in a project. |
| 13 | + |
| 14 | +**Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/protected_environments.html) |
| 15 | + |
| 16 | +## Example Usage |
| 17 | + |
| 18 | +```terraform |
| 19 | +resource "gitlab_group" "this" { |
| 20 | + name = "example" |
| 21 | + path = "example" |
| 22 | + description = "An example group" |
| 23 | +} |
| 24 | +
|
| 25 | +resource "gitlab_project" "this" { |
| 26 | + name = "example" |
| 27 | + namespace_id = gitlab_group.this.id |
| 28 | + initialize_with_readme = true |
| 29 | +} |
| 30 | +
|
| 31 | +resource "gitlab_project_environment" "this" { |
| 32 | + project = gitlab_project.this.id |
| 33 | + name = "example" |
| 34 | + external_url = "www.example.com" |
| 35 | +} |
| 36 | +
|
| 37 | +resource "gitlab_project_protected_environment" "this" { |
| 38 | + project = gitlab_project.this.id |
| 39 | + environment = gitlab_project_environment.this.name |
| 40 | +
|
| 41 | + deploy_access_levels { |
| 42 | + access_level = "developer" |
| 43 | + } |
| 44 | +} |
| 45 | +
|
| 46 | +resource "gitlab_project_protected_environment" "this" { |
| 47 | + project = gitlab_project.this.id |
| 48 | + environment = gitlab_project_environment.this.name |
| 49 | +
|
| 50 | + deploy_access_levels { |
| 51 | + group_id = gitlab_group.test.id |
| 52 | + } |
| 53 | +} |
| 54 | +
|
| 55 | +resource "gitlab_project_protected_environment" "this" { |
| 56 | + project = gitlab_project.this.id |
| 57 | + environment = gitlab_project_environment.this.name |
| 58 | +
|
| 59 | + deploy_access_levels { |
| 60 | + user_id = gitlab_user.test.id |
| 61 | + } |
| 62 | +
|
| 63 | +} |
| 64 | +``` |
| 65 | + |
| 66 | +<!-- schema generated by tfplugindocs --> |
| 67 | +## Schema |
| 68 | + |
| 69 | +### Required |
| 70 | + |
| 71 | +- `deploy_access_levels` (Block List, Min: 1, Max: 1) Array of access levels allowed to deploy, with each described by a hash. (see [below for nested schema](#nestedblock--deploy_access_levels)) |
| 72 | +- `environment` (String) The name of the environment. |
| 73 | +- `project` (String) The ID or full path of the project which the protected environment is created against. |
| 74 | + |
| 75 | +### Optional |
| 76 | + |
| 77 | +- `id` (String) The ID of this resource. |
| 78 | + |
| 79 | +<a id="nestedblock--deploy_access_levels"></a> |
| 80 | +### Nested Schema for `deploy_access_levels` |
| 81 | + |
| 82 | +Optional: |
| 83 | + |
| 84 | +- `access_level` (String) Levels of access required to deploy to this protected environment. Valid values are `developer`, `maintainer`. |
| 85 | +- `group_id` (Number) The ID of the group allowed to deploy to this protected environment. The project must be shared with the group. |
| 86 | +- `user_id` (Number) The ID of the user allowed to deploy to this protected environment. The user must be a member of the project. |
| 87 | + |
| 88 | +Read-Only: |
| 89 | + |
| 90 | +- `access_level_description` (String) Readable description of level of access. |
| 91 | + |
| 92 | +## Import |
| 93 | + |
| 94 | +Import is supported using the following syntax: |
| 95 | + |
| 96 | +```shell |
| 97 | +# GitLab protected environments can be imported using an id made up of `projectId:environmentName`, e.g. |
| 98 | +terraform import gitlab_project_protected_environment.bar 123:production |
| 99 | +``` |
0 commit comments