-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module data source is not found when running a terraform refresh on a code that is calling a module! #138
Comments
Hi @samanshariq , the error message showed:
Your Terraform code: 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
} There're two potential errors:
|
Thanks for coming back to my query. Yes below is the part of code from my locals.tf " zscl-routes = {
} rt_routes = {
} |
yes it is using correct provider details: terraform { required_providers {
} features {} |
Originally posted by @yonzhan in Azure/azure-cli#25271 (comment)
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: