taiidani / terraform-provider-jenkins

Jenkins Terraform Provider
https://registry.terraform.io/providers/taiidani/jenkins/latest
Apache License 2.0
76 stars 42 forks source link

Folder get destroyed and recreated with no change in code #160

Closed sonaikar closed 8 months ago

sonaikar commented 9 months ago

When terraform plan is executed on the code with no statefile change, it recreates the folder after destroying. It should know that resource is already present and skip the resource creation.

`resource "jenkins_folder" "new_folder" {

name = test_job_folder description = "Folder for image building jobs related jobs (managed by terraform)" folder = "folder_path" security { permissions = [ "com.cloudbees.plugins.credentials.CredentialsProvider.Create:anonymous", "com.cloudbees.plugins.credentials.CredentialsProvider.Delete:authenticated", "hudson.model.Item.Cancel:authenticated", "hudson.model.Item.Discover:anonymous", ] } } `

Provider is configured as below,

terraform { required_providers { jenkins = { source = "taiidani/jenkins" version = ">= 0.10.1" } } }

terraform plan shows below result event hough the earlier terrafom apply is successful and resources is created in jenkins. Statefile is stored in S3 bucket.

Plan: 1 to add, 0 to change, 1 to destroy.

sonaikar commented 8 months ago

This issue is observed when folder path is different than the id. Once folder path matches with folder ID this issue is resolved.