I would like to add a new VM to existing resource group in Azure which already contains 3 VMs. While running tf apply, it throws an error saying the resource group already exists.
I would like to add a new VM to existing resource group in Azure which already contains 3 VMs. While running tf apply, it throws an error saying the resource group already exists.
2
Answers
If you want to create a VM in an existing
resource group
instead of creating a new resource, you can use a data block to import the existingresource group
.Here is the updated
Terraform
code for creating 3 resources in an existing Resource Group.Terraform Apply:
Reference: Data Source: azurerm_resource_group
You can use terraform module by Azure https://github.com/Azure/terraform-azurerm-compute