terraform-provider-azuredevops icon indicating copy to clipboard operation
terraform-provider-azuredevops copied to clipboard

azuredevops_git_repository_file fails to overwrite the existing file

Open mjazwiecki opened this issue 3 years ago • 2 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and Azure DevOps Provider) Version

terraform v1.1.3 microsoft/azuredevops v0.2.0

Affected Resource(s)

  • azuredevops_git_repository_file

Terraform Configuration Files

resource "azuredevops_git_repository_file" "this" {
  repository_id       = data.azuredevops_git_repository.this.id
  file                = [path/file name]
  content             = [file content]
  branch              = "refs/heads/main"
  commit_message      = "Update"
  overwrite_on_create = true
}

Debug Output

Error: Create repositroy file failed, repositoryID: XXX, branch: refs/heads/main, file: [file name]. 
Error:  The path [path/file name] specified in the add operation already exists. 
Please specify a new path.
Parameter name: newPush

Expected Behavior

The [path/file name] file should be overwritten.

Actual Behavior

Error is being thrown as per above.

Steps to Reproduce

  1. terraform apply

Important Factoids

This is run via Azure DevOps pipeline. PAT Token has full access rights, so it is not a matter of permissions.

References

  • #0000

mjazwiecki avatar Mar 02 '22 11:03 mjazwiecki

@mjazwiecki I cannot reproduce your error, can you provide more information? I can overwritten the existed repo files.

xuzhang3 avatar Mar 04 '22 06:03 xuzhang3

I encountered this lately and it's a bit strange, because from this overwrite_on_create = true I would expect that it will just work without doing any import of the resource(s).

@mjazwiecki In my case, doing an import solved the "issue": https://registry.terraform.io/providers/microsoft/azuredevops/latest/docs/resources/git_repository_file#import

kmataru avatar Apr 18 '22 07:04 kmataru