//     MIT License
//
//     Copyright (c) Microsoft Corporation.
//
//     Permission is hereby granted, free of charge, to any person obtaining a copy
//     of this software and associated documentation files (the "Software"), to deal
//     in the Software without restriction, including without limitation the rights
//     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//     copies of the Software, and to permit persons to whom the Software is
//     furnished to do so, subject to the following conditions:
//
//     The above copyright notice and this permission notice shall be included in all
//     copies or substantial portions of the Software.
//
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//     SOFTWARE

package terraform

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestGetAddressAndResourceIDFromExistingResourceError(t *testing.T) {
	singleResourceExistsError := "Error: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.ContainerRegistry/registries/acridealgrizzly\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_container_registry\" for more information.\n\n  with module.core.module.container_registry.module.container_registry.azurerm_container_registry.this,\n  on .terraform/modules/core.container_registry.container_registry/main.tf line 1, in resource \"azurerm_container_registry\" \"this\":\n   1: resource \"azurerm_container_registry\" \"this\""
	toBeImportedResources, err := GetAddressAndResourceIDFromExistingResourceError(singleResourceExistsError)
	l := len(toBeImportedResources)
	assert.Nil(t, err)
	assert.NotNil(t, toBeImportedResources)
	assert.GreaterOrEqual(t, l, 1)

	assert.Equal(t, "/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.ContainerRegistry/registries/acridealgrizzly", toBeImportedResources["module.core.module.container_registry.module.container_registry.azurerm_container_registry.this"])
}

func TestGetAddressAndResourceIDFromExistingResourceErrorWithMultipleErrors(t *testing.T) {
	multipleResourceExistsError := "exit status 1\n\nError: creating Registry (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nRegistry Name: \"acridealgrizzly\"): polling after Create: unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.ContainerRegistry/registries/operationStatuses/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.ContainerRegistry/registries/acridealgrizzly/operationStatuses/registries-04004330-104c-4eac-99b5-627147a02a94' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.container_registry.module.container_registry.azurerm_container_registry.this,\n  on .terraform/modules/core.container_registry.container_registry/main.tf line 1, in resource \"azurerm_container_registry\" \"this\":\n   1: resource \"azurerm_container_registry\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-privatednszone.v0-1-2.2e99a5f1\" 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_template_deployment\" for more information.\n\n  with module.core.module.container_registry.module.private_dns_container_registry.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.container_registry.private_dns_container_registry/main.telemetry.tf line 9, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n   9: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: reading DNS SOA record @: unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/privateDnsZones/SOA/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/privateDnsZones/privatelink.azurecr.io/SOA/@' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.container_registry.module.private_dns_container_registry.azurerm_private_dns_zone.this,\n  on .terraform/modules/core.container_registry.private_dns_container_registry/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: checking for presence of existing Security Rule (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nNetwork Security Group Name: \"pe-nsgidealgrizzly\"\nSecurity Rule Name: \"block-internet-traffic\"): unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/securityRules/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/networkSecurityGroups/pe-nsgidealgrizzly/securityRules/block-internet-traffic' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.core_security_groups.module.pe_network_security_group.azurerm_network_security_rule.this[\"no_internet\"],\n  on .terraform/modules/core.core_security_groups.pe_network_security_group/main.rules.tf line 1, in resource \"azurerm_network_security_rule\" \"this\":\n   1: resource \"azurerm_network_security_rule\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-networksecuritygroup.v0-2-0.f302138e\" 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_template_deployment\" for more information.\n\n  with module.core.module.core_security_groups.module.pe_network_security_group.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.core_security_groups.pe_network_security_group/main.telemetry.tf line 10, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n  10: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: checking for presence of existing Security Rule (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nNetwork Security Group Name: \"vm-nsgidealgrizzly\"\nSecurity Rule Name: \"Allow-AD-Outbound\"): unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/securityRules/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/networkSecurityGroups/vm-nsgidealgrizzly/securityRules/Allow-AD-Outbound' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_network_security_rule.this[\"AllowADOutbound\"],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.rules.tf line 1, in resource \"azurerm_network_security_rule\" \"this\":\n   1: resource \"azurerm_network_security_rule\" \"this\" {\n\n\nError: checking for presence of existing Security Rule (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nNetwork Security Group Name: \"vm-nsgidealgrizzly\"\nSecurity Rule Name: \"Allow-Studio-Outbound\"): unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/securityRules/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/networkSecurityGroups/vm-nsgidealgrizzly/securityRules/Allow-Studio-Outbound' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_network_security_rule.this[\"AllowStudioOutbound\"],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.rules.tf line 1, in resource \"azurerm_network_security_rule\" \"this\":\n   1: resource \"azurerm_network_security_rule\" \"this\" {\n\n\nError: checking for presence of existing Security Rule (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nNetwork Security Group Name: \"vm-nsgidealgrizzly\"\nSecurity Rule Name: \"Allow-ARM-Outbound\"): unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/securityRules/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/networkSecurityGroups/vm-nsgidealgrizzly/securityRules/Allow-ARM-Outbound' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_network_security_rule.this[\"AllowARMOutbound\"],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.rules.tf line 1, in resource \"azurerm_network_security_rule\" \"this\":\n   1: resource \"azurerm_network_security_rule\" \"this\" {\n\n\nError: checking for presence of existing Security Rule (Subscription: \"SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS\"\nResource Group Name: \"rg-idealgrizzly\"\nNetwork Security Group Name: \"vm-nsgidealgrizzly\"\nSecurity Rule Name: \"Deny-Internet-Outbound\"): unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/networkSecurityGroups/securityRules/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/networkSecurityGroups/vm-nsgidealgrizzly/securityRules/Deny-Internet-Outbound' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_network_security_rule.this[\"DenyInternetOutbound\"],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.rules.tf line 1, in resource \"azurerm_network_security_rule\" \"this\":\n   1: resource \"azurerm_network_security_rule\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-networksecuritygroup.v0-2-0.e08a3e63\" 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_template_deployment\" for more information.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.telemetry.tf line 10, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n  10: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: checking for presence of existing Role Assignment ID for \"e2e882d7-60f1-a1cf-5844-0e6156732d5a\" (Scope \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.KeyVault/vaults/kvidealgrizzly\"): authorization.RoleAssignmentsClient#Get: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code=\"AuthorizationFailed\" Message=\"The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.KeyVault/vaults/kvidealgrizzly/providers/Microsoft.Authorization/roleAssignments/e2e882d7-60f1-a1cf-5844-0e6156732d5a' or the scope is invalid. If access was recently granted, please refresh your credentials.\"\n\n  with module.core.module.key_vault.module.key_vault.azurerm_role_assignment.this[\"deployment_user_secrets\"],\n  on .terraform/modules/core.key_vault.key_vault/main.tf line 37, in resource \"azurerm_role_assignment\" \"this\":\n  37: resource \"azurerm_role_assignment\" \"this\" {\n\n\nError: checking for presence of existing Monitor Diagnostic Setting \"Send to Log Analytics (AllLogs, AllMetrics)\" for Resource \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.KeyVault/vaults/kvidealgrizzly\": unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Insights/diagnosticSettings/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.KeyVault/vaults/kvidealgrizzly/providers/Microsoft.Insights/diagnosticSettings/Send to Log Analytics (AllLogs, AllMetrics)' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.key_vault.module.key_vault.azurerm_monitor_diagnostic_setting.this[\"defaultDiagnosticSettings\"],\n  on .terraform/modules/core.key_vault.key_vault/main.tf line 51, in resource \"azurerm_monitor_diagnostic_setting\" \"this\":\n  51: resource \"azurerm_monitor_diagnostic_setting\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-privatednszone.v0-1-2.f114f38c\" 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_template_deployment\" for more information.\n\n  with module.core.module.key_vault.module.private_dns_keyvault.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.key_vault.private_dns_keyvault/main.telemetry.tf line 9, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n   9: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: reading DNS SOA record @: unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/privateDnsZones/SOA/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net/SOA/@' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.key_vault.module.private_dns_keyvault.azurerm_private_dns_zone.this,\n  on .terraform/modules/core.key_vault.private_dns_keyvault/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-privatednszone.v0-1-2.3ea26127\" 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_template_deployment\" for more information.\n\n  with module.core.module.log_analytics_workspace.module.private_dns_workspace.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.log_analytics_workspace.private_dns_workspace/main.telemetry.tf line 9, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n   9: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: reading DNS SOA record @: unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Network/privateDnsZones/SOA/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/privateDnsZones/privatelink.workspace.azure.net/SOA/@' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.log_analytics_workspace.module.private_dns_workspace.azurerm_private_dns_zone.this,\n  on .terraform/modules/core.log_analytics_workspace.private_dns_workspace/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: checking for presence of existing Monitor Diagnostic Setting \"Send to Log Analytics (AllLogs, AllMetrics)\" for Resource \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/virtualNetworks/vnetidealgrizzly\": unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' with object id 'ddfcf162-2cf2-40cf-bd4a-49a63e248436' does not have authorization to perform action 'Microsoft.Insights/diagnosticSettings/read' over scope '/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-idealgrizzly/providers/Microsoft.Network/virtualNetworks/vnetidealgrizzly/providers/Microsoft.Insights/diagnosticSettings/Send to Log Analytics (AllLogs, AllMetrics)' or the scope is invalid. If access was recently granted, please refresh your credentials.\n\n  with module.core.module.virtual_network.module.virtual_network.azurerm_monitor_diagnostic_setting.this[\"defaultDiagnosticSettings\"],\n  on .terraform/modules/core.virtual_network.virtual_network/main.interfaces.tf line 32, in resource \"azurerm_monitor_diagnostic_setting\" \"this\":\n  32: resource \"azurerm_monitor_diagnostic_setting\" \"this\" {\n\n"
	toBeImportedResources, err := GetAddressAndResourceIDFromExistingResourceError(multipleResourceExistsError)
	l := len(toBeImportedResources)
	assert.Nil(t, err)
	assert.NotNil(t, toBeImportedResources)
	assert.GreaterOrEqual(t, l, 5)

	// Assert first and last values in the map
	// firstMatch := spm["/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourcegroups/testdeployrg/providers/Microsoft.Resources/deployments/testDeploy-f6RkAT3"]
	// assert.Equal(t, "Microsoft.Resources/deployments/write", firstMatch[0])
}

func TestGetAddressAndResourceIDFromExistingResourceErrorWithMultipleErrors2(t *testing.T) {

	multipleResourceExistsError := "exit status 1\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.ContainerRegistry/registries/acryqwme\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_container_registry\" for more information.\n\n  with module.core.module.container_registry.module.container_registry.azurerm_container_registry.this,\n  on .terraform/modules/core.container_registry.container_registry/main.tf line 1, in resource \"azurerm_container_registry\" \"this\":\n   1: resource \"azurerm_container_registry\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-networksecuritygroup.v0-2-0.3108ac10\" 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_template_deployment\" for more information.\n\n  with module.core.module.core_security_groups.module.pe_network_security_group.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.core_security_groups.pe_network_security_group/main.telemetry.tf line 10, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n  10: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Resources/deployments/46d3xgtf.res.network-networksecuritygroup.v0-2-0.dc2d2b97\" 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_template_deployment\" for more information.\n\n  with module.core.module.core_security_groups.module.vm_network_security_group.azurerm_resource_group_template_deployment.telemetry[0],\n  on .terraform/modules/core.core_security_groups.vm_network_security_group/main.telemetry.tf line 10, in resource \"azurerm_resource_group_template_deployment\" \"telemetry\":\n  10: resource \"azurerm_resource_group_template_deployment\" \"telemetry\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.blob.core.windows.net\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.blob.core.windows.net\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.azurecr.io\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.azurecr.io\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.ods.opinsights.azure.com\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.ods.opinsights.azure.com\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.vaultcore.azure.net\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.monitor.azure.com\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.monitor.azure.com\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n\nError: A resource with the ID \"/subscriptions/SSSSSSSS-SSSS-SSSS-SSSS-SSSSSSSSSSSS/resourceGroups/rg-yqwme/providers/Microsoft.Network/privateDnsZones/privatelink.agentsvc.azure-automation.net\" already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for \"azurerm_private_dns_zone\" for more information.\n\n  with module.core.module.private_dns_zones.module.private_dns_zones[\"privatelink.agentsvc.azure-automation.net\"].azurerm_private_dns_zone.this,\n  on .terraform/modules/core.private_dns_zones.private_dns_zones/main.tf line 7, in resource \"azurerm_private_dns_zone\" \"this\":\n   7: resource \"azurerm_private_dns_zone\" \"this\" {\n\n"

	toBeImportedResources, err := GetAddressAndResourceIDFromExistingResourceError(multipleResourceExistsError)
	l := len(toBeImportedResources)
	assert.Nil(t, err)
	assert.NotNil(t, toBeImportedResources)
	assert.GreaterOrEqual(t, l, 9)

}
