module data source is not found when running a terraform refresh on a code that is calling a module! #25271
Labels
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Hello Team, Basically I have run the code given below through the Azure DevOps pipeline already. Got few existing resources so want to import the state file locally . However when I am running the terraform refresh, I get the below error ;
" Error: Route Table: (Name "platform-rt-uks-legacy-prd-zscl" / Resource Group "platform-rg-uks-legacy-prd") was not found
│ with module.landing_zone.data.azurerm_route_table.zscl["uks"],
│ on ..\module-tf-landing_zone\networking.tf line 43, in data "azurerm_route_table" "zscl":
│ 43: data "azurerm_route_table" "zscl" {
"
Although the above route exists in the portal.
Here is my code below:
resource "azurerm_route_table" "rt" {
for_each = var.Location
name = replace(replace(replace(local.roleCount, "type", "rt"), "role", "lz"), "count", "0${1 + index(keys(var.Location), each.key)}")
location = azurerm_resource_group.rg[each.key].location
resource_group_name = azurerm_resource_group.rg[each.key].name
disable_bgp_route_propagation = false
tags = local.tags
lifecycle {
ignore_changes = [
tags["FirstCreated"]
]
}
}
resource "azurerm_route" "routes" {
for_each = local.rt_routes
name = each.value.rt_key
resource_group_name = azurerm_resource_group.rg[each.value.loc_key].name
route_table_name = azurerm_route_table.rt[each.value.loc_key].name
address_prefix = each.value.prefix
next_hop_type = each.value.hop_type
next_hop_in_ip_address = each.value.region == "UK South" ? local.firewalls.uksouth : local.firewalls.ukwest
}
data "azurerm_route_table" "zscl" {
provider = azurerm.prd-hub
for_each = local.zscl-rt-table
name = each.value.name
resource_group_name = each.value.rg
}
resource "azurerm_route" "zscl-routes" {
provider = azurerm.prd-hub
for_each = local.zscl-routes
name = each.value.loc_key == "Primary" ? replace(local.baseName, "type", "RouteTo") : replace(local.baseNameSecondary, "type", "RouteTo")
resource_group_name = data.azurerm_route_table.zscl[each.value.zscl_key].resource_group_name
route_table_name = data.azurerm_route_table.zscl[each.value.zscl_key].name
address_prefix = each.value.address_space[0]
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = each.value.zscl_key == "ukw" ? local.firewalls.ukwest : local.firewalls.uksouth
}
The text was updated successfully, but these errors were encountered: