Expected behaviour vs observed behaviour
Deploying multiple instances of this project to the same azure resource group fails as resource names are not unique.
Making the resource names unique by adding ${var.deployment_name} would fix this.
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/net01/subnets/snet-bastion" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_subnet" for more information.
on modules/bastion/main.tf line 7, in resource "azurerm_subnet" "bastion":
7: resource "azurerm_subnet" "bastion" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg-bastion" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_security_group" for more information.
on modules/bastion/main.tf line 15, in resource "azurerm_network_security_group" "bastion":
15: resource "azurerm_network_security_group" "bastion" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip-bastion" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_public_ip" for more information.
on modules/bastion/main.tf line 86, in resource "azurerm_public_ip" "bastion":
86: resource "azurerm_public_ip" "bastion" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Compute/availabilitySets/avset-hana" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_availability_set" for more information.
on modules/hana_node/main.tf line 24, in resource "azurerm_availability_set" "hana-availability-set":
24: resource "azurerm_availability_set" "hana-availability-set" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb-hana" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_lb" for more information.
on modules/hana_node/main.tf line 39, in resource "azurerm_lb" "hana-load-balancer":
39: resource "azurerm_lb" "hana-load-balancer" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/nic-hana01" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface" for more information.
on modules/hana_node/main.tf line 155, in resource "azurerm_network_interface" "hana":
155: resource "azurerm_network_interface" "hana" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/nic-hana02" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface" for more information.
on modules/hana_node/main.tf line 155, in resource "azurerm_network_interface" "hana":
155: resource "azurerm_network_interface" "hana" {
Error: A resource with the ID "/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/nic-iscsisrv01" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for "azurerm_network_interface" for more information.
on modules/iscsi_server/main.tf line 8, in resource "azurerm_network_interface" "iscsisrv":
8: resource "azurerm_network_interface" "iscsisrv" {
How to reproduce
Specify the step by step process to reproduce the issue. This usually would look like something like this:
Move to any of the cloud providers folder
Create the terraform.tfvars file based on terraform.tfvars.example
Run the next terraform commands:
terraform workspace new test1
terraform init
terraform plan
terraform apply -auto-approve
terraform workspace new test2
terraform init
terraform plan
terraform apply -auto-approve
Used cloud platform Azure
Used SLES4SAP version SLES15SP2
Used client machine OS Linux
Expected behaviour vs observed behaviour Deploying multiple instances of this project to the same azure resource group fails as resource names are not unique.
Making the resource names unique by adding
${var.deployment_name}
would fix this.How to reproduce Specify the step by step process to reproduce the issue. This usually would look like something like this:
terraform.tfvars
file based onterraform.tfvars.example
Run the next terraform commands: