jdamata / terraform-provider-sonarqube

Terraform provider for managing Sonarqube configuration
GNU General Public License v3.0
62 stars 51 forks source link

After redeploy sonarqube server, some settings are detected with error not as a drift #197

Open humpalu opened 10 months ago

humpalu commented 10 months ago

Hi there,

Thank you for opening an issue.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed. Terraform v1.4.5

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

terraform {
   backend "s3" {
     bucket = "xxxx"
     key    = "xxxx/terraform.tfstate"
     region = "eu-central-1"
   }

  required_providers {
    sonarqube = {
      source = "jdamata/sonarqube"
    }
  }

}

resource "sonarqube_permissions" "admin_permission" {
  group_name  = "xxxxx-xxxxx-xxxxx-xxxxx"
  permissions = ["admin", "gateadmin", "profileadmin", "provisioning", "scan"]
}

resource "sonarqube_setting" "sonar_core_serverBaseURL" {
  key   = "sonar.core.serverBaseURL"
  value = var.sonarqube_host
}

resource "sonarqube_setting" "sonar_auth_saml_providerId" {
  key   = "sonar.auth.saml.providerId"
  value = "https://sts.windows.net/dxxxx-xxxx-xxxx-xxxx"
}

resource "sonarqube_setting" "sonar_auth_saml_loginUrl" {
  key   = "sonar.auth.saml.loginUrl"
  value = "https://login.microsoftonline.com/ddxxxx-xxxx-xxxx-xxxx/saml2"
}

Expected Behavior

After the redeploy of the server, these changes should be recognized as a drift and terraform tries to recreate them

Actual Behavior

error messages

│ Error: resourceSonarqubePermissionsRead: Unable to find group permissions for group: xxxxx-xxxxx-xxxxx-xxxxx
│ 
│   with sonarqube_permissions.admin_permission,
│   on main.tf line 52, in resource "sonarqube_permissions" "admin_permission":
│   52: resource "sonarqube_permissions" "admin_permission" {
│ 
╵
╷
│ Error: resourceSonarqubeSettingsRead: Failed to find setting: sonar.core.serverBaseURL
│ 
│   with sonarqube_setting.sonar_core_serverBaseURL,
│   on main.tf line 60, in resource "sonarqube_setting" "sonar_core_serverBaseURL":
│   60: resource "sonarqube_setting" "sonar_core_serverBaseURL" {
│ 
╵
╷
│ Error: resourceSonarqubeSettingsRead: Failed to find setting: sonar.auth.saml.providerId
│ 
│   with sonarqube_setting.sonar_auth_saml_providerId,
│   on main.tf line 87, in resource "sonarqube_setting" "sonar_auth_saml_providerId":
│   87: resource "sonarqube_setting" "sonar_auth_saml_providerId" {
│ 

│ Error: resourceSonarqubeSettingsRead: Failed to find setting: sonar.auth.saml.loginUrl
│ 
│   with sonarqube_setting.sonar_auth_saml_loginUrl,
│   on main.tf line 94, in resource "sonarqube_setting" "sonar_auth_saml_loginUrl":
│   94: resource "sonarqube_setting" "sonar_auth_saml_loginUrl" {
│ 

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

jdamata commented 10 months ago

Looking for a clarification here on what redeploy means. Does that mean restart? Or a brand new deployment?

humpalu commented 10 months ago

@jdamata In this context deploy means, brand new deployment.

Currently if I redeploy the server, I need to remove the sonarqube_setting resources from the .tfstate or create a new local state and migrate after the deployment