microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
387 stars 279 forks source link

Changing the file attribute in azuredevops_git_repository_file will not delete and create the old file without changing the ressource name #1073

Closed philippfrenzel closed 1 week ago

philippfrenzel commented 5 months ago

Community Note

Terraform (and Azure DevOps Provider) Version

Task : Terraform Description : Execute terraform commands to manage resources on AzureRM, Amazon Web Services(AWS) and Google Cloud Platform(GCP) Version : 4.238.25 Author : Microsoft Corporation Help : Learn more about this task

Affected Resource(s)

resource "azuredevops_git_repository" "synapse_backend" {
  project_id     = data.azuredevops_project.workbench.id
  name           = "dap-synapse-backend"
  default_branch = "refs/heads/main"
  initialization {
    init_type = "Clean"
  }
  lifecycle {
    ignore_changes = [
      initialization,
    ]
  }
}

resource "azuredevops_git_repository_file" "default_synapse_yml_testdir" {
  count               = length(azuredevops_git_repository.synapse_backend)
  repository_id       = azuredevops_git_repository.synapse_backend.id
  file                = "testdir/azure-pipelines.yml"
  content             = file("${path.module}/assets/syn-release.yml")
  branch              = "refs/heads/main"
  commit_message      = "Add Azure-pipelines in a new folder.yml"
  overwrite_on_create = true

  lifecycle {
    ignore_changes = [
      file,
      content,
      commit_message
    ]
  }
}

Terraform Configuration Files

see above

Debug Output

Non, says it worked, but didn't

Expected Behavior

Move a file from one directory to another

Actual Behavior

File keeps untouched

Steps to Reproduce

Modify e.g. the filename from test.yml to testtwo.yml without changing anything else within your terraform.

  1. terraform apply
slideroh commented 1 month ago

I'd say you basically have ignore_changes on file, so rename filename shouldn't trigger terraform change.

xuzhang3 commented 1 month ago

@philippfrenzel the file changes was ignored by ignore_changes