Azure devops pipeline with terraform fails with error "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"

Babychen Daisy, Dona 20 Reputation points
2023-08-05T23:08:28.61+00:00

Azure devops pipeline for terraform failed with error

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.

How to import this in azure settings. I gave in additional command. But it gave error

1mError: Too many command line arguments
2023-08-05T18:21:46.5869211Z │ 
2023-08-05T18:21:46.5869722Z │ Expected at most one positional argument.
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
    2023-08-06T03:14:01.8666667+00:00

    It would be best if you used the terraform import command to import an existing resource into Terraform state. The correct syntax for importing a resource is as follows:

    terraform import RESOURCE_TYPE.RESOURCE_NAME ID
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.