terraform-azurerm-caf
terraform-azurerm-caf copied to clipboard
Bug report-Pick up data_sources from a different landing zone
Is there an existing issue for this?
- [X] I have searched the existing issues
Community Note
- Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Version of the module you are using
5.7.5
Rover Version
aztfmod/rover:1.5.6-2309.0507
Terraform Version
1.5.6
AzureRM Provider Version
No response
Affected Resource(s)/Data Source(s)
N/A
Terraform Configuration Files
N/A
Expected Behaviour
By able to reference data_sources with lz_key
Actual Behaviour
The datasource has not been found in combined_objects_networking object
Steps to Reproduce
N/A
Important Factoids
No response
References
I am not sure if it's bug or a feature request, but I was expecting to be able to reference data_sources by lz_key. Here is an example:
- Create a landing zone:
landingzone = {
backend_type = "azurerm"
level = "level2"
key = "datasources"
global_settings_key = "identity"
tfstates = {
identity = {
tfstate = "identity.tfstate"
level = "lower"
}
}
}
data_sources = {
vnets = {
my_vnet= {
id = "/subscriptions/xxx/resourceGroups/vnet-rg/providers/Microsoft.Network/virtualNetworks/my-vnet"
}
}
}
- Terraform apply this landing zone. Note: When checking the state file, I dont see any reference of the vnet
- Reference datasources state in in another landing zone
landingzone = {
backend_type = "azurerm"
level = "level2"
key = "connectivity_private_dns_prod"
tfstates = {
datasources = {
tfstate = "datasources.tfstate"
}
}
}
private_dns_vnet_links = {
my_vnet = {
vnet_key = "my_vnet"
lz_key = "datasources"
private_dns_zones = {
my_private_dns_zone= {
name = "my_dns_zone"
key = "my_key"
}
}
}
}
Its working when the data_sources object is created in the same landingzone (with no lz_key).
Error returned:
on /home/vsts_azpcontainer/nwb/rover_jobs/20231009170833188976296/modules/solution/networking_private_dns.tf line 59, in module "private_dns_vnet_links":
59: virtual_network_id = can(each.value.virtual_network_id) ? each.value.virtual_network_id : local.combined_objects_networking[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.vnet_key].id
├────────────────
│ each.value.lz_key is "datasources"
│ each.value.vnet_key is "my_vnet"
│ local.client_config.landingzone_key is "connectivity_private_dns_prod"
│ local.combined_objects_networking is object with 4 attributes
The given key does not identify an element in this collection value.