Terraform 12
Provider Version: >= 0.0.1
It was initially created when it was 0.0.1... now its 0.1.0
azuredevops_git_repositoryresource "azuredevops_git_repository" "repo" {
project_id = data.azuredevops_project.project.id
name = "our-repo"
initialization {
init_type = "Clean"
}
}
This is an existing repo... what should have happened is nothing
It wants to replace the repo and add:
source_type = 'Git'
even though this is not meant to be required unless the init_type is 'Import'. If you do add source_type='Git' it then complains that there is no source_url.
This has changed however, as it never used to do this.
@kevinmatthews-kpmg DevOps will create a default repo with the same name as project. If you want reuse the default repository, you can use data source azuredevops_git_repository, you don't need to create an extra repo.
Example:
resource "azuredevops_project" "project" {
name = "Sample Project"
visibility = "private"
version_control = "Git"
work_item_template = "Agile"
}
data "azuredevops_git_repository" "myrepo" {
project_id = azuredevops_project.project.id
name="Sample Project"
}
output "repo" {
value = data.azuredevops_git_repository.myrepo
}

@xuzhang3 I don't think your response addresses the issue raised.
@kevinmatthews-kpmg we have hit the same issue. We have progressed with the updated provider by hacking the state file, so that within the azuredevops_git_repository resource, the initialization block changes from:
"initialization": [
{
"init_type": "Clean",
"source_type": "",
"source_url": ""
}
],
to
"initialization": [
{
"init_type": "Clean",
"source_type": "Git",
"source_url": ""
}
],
As you note, trying to do this using the terraform configuration itself doesn't work because it if source_type is provided, then source_url is required. And then source_url can't be provided as an empty value.
Obviously, hacking the state file is not a good solution, so I think this is a valid issue that needs addressed.
@ChrisF987 I get your point , we add the 'Git' as the default repo type and add an constraint for the source_type which need source_url to be configured. This looks like a bug.
I faced the same issue, @xuzhang3 any ETA to fix it?
I added
lifecycle {
prevent_destroy = false
}
to protect our repos, but our CI is totally broken
@ChrisF987 I did exact same thing and hacked away at the state file, it was no good though as it still wanted the source url when I reran the terraform so failed.
The only thing I did to fix this was to change provider back to 0.0.1 which fixed it for now and allows me to continue to use our CI until the provider has been fixed.
Hi @poligraph @kevinmatthews-kpmg If you add source_type = "Git" after you upgrade the provider to v0.1.0, a workaround for this is is remove the source_type = "Git" configure , provider will set the source_type=Git by default. Though the state file have the source_type = "Git", but this won't trigger the source_url check.
@xuzhang3 i did try this, however it wants to destroy and recreate the repo, which is no good for us.
@xuzhang3 I have the same issue, any ETA to fix it? seems like a critical bug
We upgraded the azuredevops provider from 0.0.1 to 0.1.0 too and now hitting the same issue:
terraform plan output (truncated - more than 100 more affected):
```
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# module.azuredevops_git_repository_resources.azuredevops_git_repository.repository["XYZ"] must be replaced
-/+ resource "azuredevops_git_repository" "repository" {
[...]
- initialization { # forces replacement
- init_type = "Clean" -> null
}
+ initialization { # forces replacement
+ init_type = "Clean"
+ source_type = "Git"
}
}
```
How can we solve this issue in the meantime and when is a fix expected?
EDIT: our workaround that solved the issue (for how long?) was to search and replace "source_type": "" with "source_type": "Git" in the state file
The source_type default value has been removed.
If your initialization.init_type is not Import:
.tfstate, there will be no diff during plan && apply lifecycle. .tfstate, there will be a diff during plan && apply lifecycle as the source_type default value has been removed.@xuzhang3 I have upgraded from 0.1.0 to 0.1.1 and still have that issue
~ initialization {
init_type = "Clean"
- source_type = "Git" -> null # forces replacement
}
@poligraph This is correct, v0.1.0 have default value Git while in v0.1.1 the default value has been removed. You can remove the source_type value from .tfstate manually or execute the terraform apply command (because the source_type is ForceNew=true, the apply command will destroy the old repo and create a new one)
@xuzhang3 thanks for workaround - i fixed state file and it works now.
Close this issue, feel free to open another issue if you have questions.
Most helpful comment
@ChrisF987 I get your point , we add the 'Git' as the default repo type and add an constraint for the
source_typewhich needsource_urlto be configured. This looks like a bug.