SOLVED

problem update tfstate with resources

Contributor

hello, 

 

i have created a resource groupe with vnet via terraform using this pipeline

 

hamma91_0-1648067979008.png

the RG and vnet are created correctly. 

 

BUT, when i update the code in the repos that i want to add the creation of a new resource like a subnet for examle. the job of pipeline work automatically and i have this error : 

 

 

RG is existing , i don't undrestant how to make the update automatically for resources. 

 

hamma91_1-1648068141696.png

 

and how can i stop the automatic lunch of the pipeline after modifing the code in the repos ?

 

Thanks 

 

1 Reply
best response confirmed by hamma91 (Contributor)
Solution
You need to disable the CI trigger by adding
trigger: none
https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&WT.m...

Regarding the error in the screenshot it simply means that a resource with the same name has been created manually or by terraform but not kept in the state file .
If the resource group empty the easiest way is to delete it and redeploy it . If it's not possible you need to do a terraform import an option documented here : https://www.terraform.io/cli/import/usage