Share via

getting error while creating resource group in Terraform

Ashwani Verma 1 Reputation point
2022-05-03T07:01:53.997+00:00

while running this command

terraform apply -var="location=Central India"

Error: A resource with the ID "/subscriptions/xxxxxxxxxxxxxxx/resourceGroups/NoBSDevOpsMonolith" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_resource_group" for more information.

│ with azurerm_resource_group.monolithRG,
│ on main.tf line 10, in resource "azurerm_resource_group" "monolithRG":
│ 10: resource "azurerm_resource_group" "monolithRG" {

to rectify when ran this command

resource "azurerm_resource_group" "NoBSDevOpsMonolith" {
name = "var.NoBSDevOpsMonolith"
location = "var.Central India"
}

getting this error
resource: The term 'resource' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

i followed so many articles like "https://gmusumeci.medium.com/how-to-import-an-existing-azure-resource-in-terraform-6d585f93ea02" but no luck so far

appreciate anyone help to get rid of this error

Azure Cloud Services
Azure Cloud Services

An Azure platform as a service offer that is used to deploy web and cloud applications.


Your answer

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