resource/service_slack: changing the ID was a breaking change
GitLab Provider version
3.9.0 and above
GitLab version
GitLab Enterprise Edition 14.9.2-ee
Terraform version
1.1.7
Relevant Terraform Configuration
resource "gitlab_service_slack" "slack" {
project = gitlab_project.git-project.id
webhook = var.service_integration_slack["webhook"]
username = var.service_integration_slack["username"]
push_events = true
issues_events = true
confidential_issues_events = true
confidential_note_events = true
merge_requests_events = true
tag_push_events = true
note_events = true
pipeline_events = true
wiki_page_events = true
branches_to_be_notified = "all"
confidential_issue_channel = lookup(var.service_integration_slack, "confidential_issue_channel", lookup(var.service_integration_slack, "channel", null))
issue_channel = lookup(var.service_integration_slack, "issue_channel", lookup(var.service_integration_slack, "channel", null))
merge_request_channel = lookup(var.service_integration_slack, "merge_request_channel", lookup(var.service_integration_slack, "channel", null))
note_channel = lookup(var.service_integration_slack, "note_channel", lookup(var.service_integration_slack, "channel", null))
pipeline_channel = lookup(var.service_integration_slack, "pipeline_channel", lookup(var.service_integration_slack, "channel", null))
push_channel = lookup(var.service_integration_slack, "push_channel", lookup(var.service_integration_slack, "channel", null))
tag_push_channel = lookup(var.service_integration_slack, "tag_push_channel", lookup(var.service_integration_slack, "channel", null))
wiki_page_channel = lookup(var.service_integration_slack, "wiki_page_channel", lookup(var.service_integration_slack, "channel", null))
count = length(var.service_integration_slack) > 0 ? 1 : 0
}
Relevant log output
│ Error: GET https://myhost/api/v4/projects/2141/services/slack: 403 {message: 403 Forbidden}
│
│ with module.terraform.module.myproject.gitlab_service_slack.slack[0],
│ on .terraform/modules/terraform.myproject/gitlab-project.tf line 65, in resource "gitlab_service_slack" "slack":
│ 65: resource "gitlab_service_slack" "slack" {
│
Description
Changing the ID of gitlab_service_slack resources from d.SetId(fmt.Sprintf("%d", service.ID)) to d.SetId(project) was a breaking change.
All existing gitlab_service_slack are now broken as their old ID is now considered the ID of their project, resulting in errors if you do not have the permissions to access the referenced project, e.g.:
│ Error: GET https://myhost/api/v4/projects/2141/services/slack: 403 {message: 403 Forbidden}
│
│ with module.terraform.module.myproject.gitlab_service_slack.slack[0],
│ on .terraform/modules/terraform.myproject/gitlab-project.tf line 65, in resource "gitlab_service_slack" "slack":
│ 65: resource "gitlab_service_slack" "slack" {
│
Here, 2141 was the Slack service ID and is now considered a project ID.
And it probably has worse implications if you can access the related project. Originally posted by @pdecat in https://github.com/gitlabhq/terraform-provider-gitlab/pull/821#discussion_r842671210