|
| 1 | +--- |
| 2 | +page_title: "Terraform GitLab Provider Version 19.0 Upgrade Guide" |
| 3 | +subcategory: "Upgrade Guides" |
| 4 | +--- |
| 5 | + |
| 6 | +# Upgrade to Terraform GitLab Provider Version 19.0 |
| 7 | + |
| 8 | +This is a draft and is subject to change. |
| 9 | + |
| 10 | +The GitLab 19.0 major milestone introduced some breaking changes that this release addresses. |
| 11 | +The provider also has some breaking changes which may require actions on the users side. |
| 12 | +These are described below: |
| 13 | + |
| 14 | +## Resource renames |
| 15 | + |
| 16 | +If you are using any of the following resources, you will need to complete these actions: |
| 17 | + |
| 18 | +- Rename the resource reference in your terraform code. For example: |
| 19 | + |
| 20 | + ```hcl |
| 21 | + resource "gitlab_integration_jira" "jira_setup" { |
| 22 | + ... |
| 23 | + } |
| 24 | + ``` |
| 25 | + |
| 26 | + Becomes |
| 27 | + |
| 28 | + ```hcl |
| 29 | + resource "gitlab_project_integration_jira" "jira_setup" { |
| 30 | + ... |
| 31 | + } |
| 32 | + ``` |
| 33 | + |
| 34 | +- Perform a state move using one of the terraform options: |
| 35 | + - Command line with [state mv](https://developer.hashicorp.com/terraform/cli/commands/state/mv). For example: |
| 36 | + |
| 37 | + ```bash |
| 38 | + terraform state mv 'gitlab_integration_jira.jira_setup' 'gitlab_project_integration_jira.jira_setup' |
| 39 | + ``` |
| 40 | + |
| 41 | + - State [moved block](https://developer.hashicorp.com/terraform/language/block/moved) and running an apply. For example: |
| 42 | + |
| 43 | + ```hcl |
| 44 | + moved { |
| 45 | + from = gitlab_integration_jira.jira_setup |
| 46 | + to = gitlab_project_integration_jira.jira_setup |
| 47 | + } |
| 48 | + ``` |
| 49 | + |
| 50 | +### Renamed resources |
| 51 | + |
| 52 | +- `gitlab_deploy_token` renamed to `gitlab_project_deploy_token` |
| 53 | +- `gitlab_integration_custom_issue_tracker` renamed to `gitlab_project_integration_custom_issue_tracker` |
| 54 | +- `gitlab_integration_emails_on_push` renamed to `gitlab_project_integration_emails_on_push` |
| 55 | +- `gitlab_integration_external_wiki_resource` renamed to `gitlab_project_integration_external_wiki_resource` |
| 56 | +- `gitlab_integration_github` renamed to `gitlab_project_integration_github` |
| 57 | +- `gitlab_integration_harbor` renamed to `gitlab_project_integration_harbor` |
| 58 | +- `gitlab_integration_jenkins` renamed to `gitlab_project_integration_jenkins` |
| 59 | +- `gitlab_integration_jira` renamed to `gitlab_project_integration_jira` |
| 60 | +- `gitlab_integration_mattermost` renamed to `gitlab_project_integration_mattermost` |
| 61 | +- `gitlab_integration_microsoft_teams` renamed to `gitlab_project_integration_microsoft_teams` |
| 62 | +- `gitlab_integration_pipelines_email` renamed to `gitlab_project_integration_pipelines_email` |
| 63 | +- `gitlab_integration_redmine` renamed to `gitlab_project_integration_redmine` |
| 64 | +- `gitlab_integration_telegram` renamed to `gitlab_project_integration_telegram` |
| 65 | +- `gitlab_label` renamed to `gitlab_project_label` |
| 66 | +- `gitlab_project_mirror` renamed to `gitlab_project_push_mirror` |
| 67 | + |
| 68 | +## Resource replacements |
| 69 | + |
| 70 | +- `gitlab_runner` replaced by `gitlab_user_runner`. |
| 71 | + - This switches to the [newer authentication method](https://docs.gitlab.com/runner/register/#register-with-a-runner-authentication-token) for registering runners. |
| 72 | + |
| 73 | +## Attribute swaps |
| 74 | + |
| 75 | +### Datasources |
| 76 | + |
| 77 | +- `gitlab_projects._link` renamed to `gitlab_projects.links`. |
| 78 | + - Can be directly replaced with no other changes required. |
| 79 | + |
| 80 | +### Resources |
| 81 | + |
| 82 | +- `gitlab_integration_slack.notify_only_default_branch` switch to `gitlab_integration_slack.branches_to_be_notified`. |
| 83 | + - If `notify_only_default_branch` was `false`, set `branches_to_be_notified` to `all`. |
| 84 | + - If `notify_only_default_branch` was `true`, set `branches_to_be_notified` to `default`. |
| 85 | +- `gitlab_project_share_group.access_level` switch to `gitlab_project_share_group.group_access` |
| 86 | + - Can be directly replaced with no other changes required. |
| 87 | +- `gitlab_project` |
| 88 | + - For all of the following, replace `true` with `enabled` and `false` with `disabled`: |
| 89 | + - `issues_enabled` switch to `issues_access_level` |
| 90 | + - `merge_requests_enabled` switch to `merge_requests_access_level` |
| 91 | + - `pipelines_enabled` switch to `builds_access_level` |
| 92 | + - `wiki_enabled` switch to `wiki_access_level` |
| 93 | + - `snippets_enabled` switch to `snippets_access_level` |
| 94 | + - `container_registry_enabled` switch to `container_registry_access_level` |
| 95 | + - `restrict_user_defined_variables` switch to `ci_pipeline_variables_minimum_override_role` |
| 96 | + - If `restrict_user_defined_variables` was `false`, set `ci_pipeline_variables_minimum_override_role` to `developer`. |
| 97 | + - If `restrict_user_defined_variables` was `true`, set `ci_pipeline_variables_minimum_override_role` to `maintainer`. |
| 98 | + - `tags` switch to `topics` |
| 99 | + - Can be directly replaced with no other changes required. |
| 100 | + - `public_builds` switch to `public_jobs` |
| 101 | + - Can be directly replaced with no other changes required. |
| 102 | +- `gitlab_application_settings.default_branch_protection` switch to `gitlab_application_settings.default_branch_protection_defaults`. As a rough guide: |
| 103 | + - If `default_branch_protection` was `0`: |
| 104 | + |
| 105 | + ```hcl |
| 106 | + default_branch_protection_defaults { |
| 107 | + allowed_to_push = [30] # Developer |
| 108 | + allowed_to_merge = [30] # Developer |
| 109 | + allow_force_push = true |
| 110 | + } |
| 111 | + ``` |
| 112 | +
|
| 113 | + - If `default_branch_protection` was `1`: |
| 114 | + |
| 115 | + ```hcl |
| 116 | + default_branch_protection_defaults { |
| 117 | + allowed_to_push = [30] # Developer |
| 118 | + allowed_to_merge = [40] # Maintainer |
| 119 | + allow_force_push = false |
| 120 | + } |
| 121 | + ``` |
| 122 | +
|
| 123 | + - If `default_branch_protection` was `2`: |
| 124 | + |
| 125 | + ```hcl |
| 126 | + default_branch_protection_defaults { |
| 127 | + allowed_to_push = [40] # Maintainer |
| 128 | + allowed_to_merge = [40] # Maintainer |
| 129 | + allow_force_push = false |
| 130 | + } |
| 131 | + ``` |
| 132 | +
|
| 133 | + - If `default_branch_protection` was `3`: |
| 134 | + |
| 135 | + ```hcl |
| 136 | + default_branch_protection_defaults { |
| 137 | + allowed_to_push = [] |
| 138 | + allowed_to_merge = [40] # Maintainer |
| 139 | + allow_force_push = false |
| 140 | + } |
| 141 | + ``` |
| 142 | +
|
| 143 | +## Attributes replaced by new resources |
| 144 | +
|
| 145 | +- `gitlab_project.approvals_before_merge` replaced by `gitlab_project_approval_rule` |
| 146 | + - All projects have a default approval rule, regardless of whether `approvals_before_merge` is in use. |
| 147 | + - By default, `gitlab_project_approval_rule` will automatically import the default approval rule. |
| 148 | + - Remove `gitlab_project.approvals_before_merge`. |
| 149 | + - Add the `gitlab_project_approval_rule` resource, and set attribute `approvals_required` to the value that was stored in `approvals_before_merge`. |
| 150 | + - Apply the changes |
| 151 | + - During the update process, the approvers total will be set to zero by the project resource for a short time. The approval rule resource will then import the rule and update the approvers total to the desired amount in the same apply operation. |
| 152 | + - Example old config: |
| 153 | +
|
| 154 | + ```hcl |
| 155 | + resource "gitlab_project" "project" { |
| 156 | + approvals_before_merge = 2 |
| 157 | + } |
| 158 | + ``` |
| 159 | +
|
| 160 | + - Example of new config: |
| 161 | +
|
| 162 | + ```hcl |
| 163 | + resource "gitlab_project_approval_rule" "default_rule" { |
| 164 | + project = gitlab_project.project.id |
| 165 | + name = "Default" |
| 166 | + approvals_required = 2 |
| 167 | + } |
| 168 | + ``` |
| 169 | +
|
| 170 | +## Resources removed |
| 171 | +
|
| 172 | +These resources are for long deprecated features of GitLab. |
| 173 | +The functionality will no longer be available in GitLab 19.0, so these resources will also be removed. |
| 174 | +
|
| 175 | +- `gitlab_group_cluster` |
| 176 | +- `gitlab_instance_cluster` |
| 177 | +- `gitlab_project_cluster` |
0 commit comments