Azure appservice creation with terraform is giving error below:
A resource with the ID "/providers/Microsoft.Web/sourceControls/GitHub" already exists – to be managed via Terraform this resource needs to be imported into the State.
I ran the below command-
terraform import azurerm_source_control_token.dobble_token /providers/Microsoft.Web/sourcecontrols/GitHub
But it gives the error below:-
ID must be exactly "/providers/Microsoft.Web/sourceControls/GitHub".
I gave id in the format below:-
azurerm_source_control_token.dobble_token
as "/providers/Microsoft.Web/sourceControls/GitHub"
. I Still face the same error.
Could someone help me resolve this?
2
Answers
I tried the below
terraform code
to create app Service with source control from this document.My main.tf code referred from the document above but modified to print source_control resource id:-
Print the resource id of source control by adding the code snippet below in main.tf code:-
And then import the source control latest state with the command below by using the resource id printed in the terminal with the code above.
As my resource is already managed by terraform it gave me the warning above.
@SiddheshDesai Could you help me in resolving this import statement.
It is giving the error
2023-08-31T09:57:03.4764371Z ##[error]Error: The process ‘C:hostedtoolcachewindowsterraform1.5.6x64terraform.exe’ failed with exit code 127
2023-08-31T09:57:03.4832459Z ##[section]Finishing: Terraform import
2023-08-31T09:57:03.4121721Z [command]C:hostedtoolcachewindowsterraform1.5.6x64terraform.exe "terraform import azurerm_source_control_token.dobble_token1 /providers/Microsoft.Web/sourceControls/GitHub"
2023-08-31T09:57:03.4641190Z Usage: terraform [global options] [args]