SOLVED

problem update tfstate with resources

%3CLINGO-SUB%20id%3D%22lingo-sub-3263507%22%20slang%3D%22en-US%22%3Eproblem%20update%20tfstate%20with%20resources%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3263507%22%20slang%3D%22en-US%22%3E%3CP%3Ehello%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20have%20created%20a%20resource%20groupe%20with%20vnet%20via%20terraform%20using%20this%20pipeline%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hamma91_0-1648067979008.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358086iBD3266EEB6149386%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22hamma91_0-1648067979008.png%22%20alt%3D%22hamma91_0-1648067979008.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3Ethe%20RG%20and%20vnet%20are%20created%20correctly.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBUT%2C%20when%20i%20update%20the%20code%20in%20the%20repos%20that%20i%20want%20to%20add%20the%20creation%20of%20a%20new%20resource%20like%20a%20subnet%20for%20examle.%20the%20job%20of%20pipeline%20work%20automatically%20and%20i%20have%20this%20error%20%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERG%20is%20existing%20%2C%20i%20don't%20undrestant%20how%20to%20make%20the%20update%20automatically%20for%20resources.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hamma91_1-1648068141696.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F358087iC338AE8FA3E24CD4%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22hamma91_1-1648068141696.png%22%20alt%3D%22hamma91_1-1648068141696.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20how%20can%20i%20stop%20the%20automatic%20lunch%20of%20the%20pipeline%20after%20modifing%20the%20code%20in%20the%20repos%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%26nbsp%3B%3C%2FP%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3265233%22%20slang%3D%22en-US%22%3ERe%3A%20problem%20update%20tfstate%20with%20resources%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3265233%22%20slang%3D%22en-US%22%3EYou%20need%20to%20disable%20the%20CI%20trigger%20by%20adding%3CBR%20%2F%3Etrigger%3A%20none%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Frepos%2Fazure-repos-git%3Fview%3Dazure-devops%26amp%3BWT.mc_id%3DAZ-MVP-5004274%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Frepos%2Fazure-repos-git%3Fview%3Dazure-devops%26amp%3BWT.mc_id%3DAZ-MVP-5004274%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3ERegarding%20the%20error%20in%20the%20screenshot%20it%20simply%20means%20that%20a%20resource%20with%20the%20same%20name%20has%20been%20created%20manually%20or%20by%20terraform%20but%20not%20kept%20in%20the%20state%20file%20.%3CBR%20%2F%3EIf%20the%20resource%20group%20empty%20the%20easiest%20way%20is%20to%20delete%20it%20and%20redeploy%20it%20.%20If%20it's%20not%20possible%20you%20need%20to%20do%20a%20terraform%20import%20an%20option%20documented%20here%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.terraform.io%2Fcli%2Fimport%2Fusage%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.terraform.io%2Fcli%2Fimport%2Fusage%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
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