diagnostic_event_hub_namespace
options posted anywhere?
name
and location
resource_groups = {
level0 = {
"Reader" = {
azuread_groups = {
keys = ["caf_launchpad_Reader"]
}
}
}
# naming convention
resource "azurecaf_name" "rg" {
name = var.resource_group_name
resource_type = "azurerm_resource_group"
prefixes = var.global_settings.prefixes
random_length = var.global_settings.random_length
clean_input = true
passthrough = var.global_settings.passthrough
use_slug = var.global_settings.use_slug
}
resource "azurerm_resource_group" "rg" {
name = azurecaf_name.rg.result
location = var.global_settings.regions[lookup(var.settings, "region", var.global_settings.default_region)]
tags = merge(
var.tags,
lookup(var.settings, "tags", {})
)
}
having used many TF modules, it's pretty standard to do something like
module "resource_group" "rg" {
source = "git::https://github.com/aztfmod/terraform-azurerm-caf/blob/master/modules/resource_group/module.tf"
version = "1.0.0"
name = var.rg_name
location = var.rg_location
tags = var.rg_tags
}
How is it better to use this round about way of specifying configs?
if nothing else, it'd be nice to have things structured as something that matches the CAF config definition like
resource_group = {
name = "Reader"
azuread_groups = [group1, group2]
caf_level = level0
}
My real confusion is how do I know which landing zone configs the resource group needs to specify. Where is the landing zone configuration spec?
Importing KeyVault with rover 🔐
Command used
rover -lz /tf/caf/landingzones/caf_solution/ -tfstate example.tfstate -var-folder /tf/caf/configuration/example/level3/example-linux-vm -parallelism 30 -env example -level level3 -a import module.solution.module.keyvaults[\"example_vm_rg1\"].module.initial_policy[0].module.logged_in_user[\"logged_in_user\"].azurerm_key_vault_access_policy.policy /subscriptions/<subscription-id>/resourceGroups<example>-virtual-machine-rg1/providers/Microsoft.KeyVault/vaults/<vault-name>/objectId/<objectId>
I could use some help importing Keyvault. Seeing the following errors:
Terraform import return code: 1
Terraform returned errors:
╷
│ Error: Invalid index
│
│ on /home/vscode/.terraform.cache/modules/solution/modules/compute/virtual_machine/output.tf line 39, in output "ssh_keys":
│ 39: ssh_private_key_pem = azurerm_key_vault_secret.ssh_private_key[local.os_type].name
│ ├────────────────
│ │ azurerm_key_vault_secret.ssh_private_key is object with no attributes
│ │ local.os_type is "linux"
│
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│
│ on /home/vscode/.terraform.cache/modules/solution/modules/compute/virtual_machine/output.tf line 40, in output "ssh_keys":
│ 40: ssh_public_key_open_ssh = azurerm_key_vault_secret.ssh_public_key_openssh[local.os_type].name
│ ├────────────────
│ │ azurerm_key_vault_secret.ssh_public_key_openssh is object with no attributes
│ │ local.os_type is "linux"
│
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│
│ on /home/vscode/.terraform.cache/modules/solution/modules/compute/virtual_machine/output.tf line 41, in output "ssh_keys":
│ 41: ssh_private_key_open_ssh = azurerm_key_vault_secret.ssh_public_key_openssh[local.os_type].name #for backard compat, wrong name, will be removed in future version.
│ ├────────────────
│ │ azurerm_key_vault_secret.ssh_public_key_openssh is object with no attributes
│ │ local.os_type is "linux"
│
│ The given key does not identify an element in this collection value.
╵
Error on or near line 573: Error running terraform import; exiting with status 2003
@arnaudlh following your youtube video https://www.youtube.com/watch?v=fqgv4Wsvo88 I'm doing nothing different from you apart from the location of UKSouth and my own password, and I get the below error message.
TASK [wait for the WinRM port to come online] *****************************************************************************************************************************
ok: [localhost]
PLAY [Setup the CAF development tools] ************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************
fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "ntlm: the specified credentials were rejected by the server", "unreachable": true}
PLAY RECAP ****************************************************************************************************************************************************************
localhost : ok=12 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
I'm able to log into the VM using RDP with the king.admin and password I have set. Are you able to advise why its failing for me?
enterprise scale
repo to build out the management group structure, but using the CAF unified repo to deploy resources appears to be suicide at this point.
Error: Error in function call
on /home/vsts_azpcontainer/modules/solution/modules/networking/virtual_hub_route_tables/route_local.tf line 9, in locals:
9: nextHop = coalesce(
10: try(value.next_hop_id, ""),
11: try(var.remote_objects.virtual_hub_connections[value.next_hop.lz_key][value.next_hop.key].id, ""),
12: try(var.remote_objects.azurerm_firewalls[value.next_hop.lz_key][value.next_hop.key].id, ""),
13: try(var.resource_ids[value.next_hop.resource_type][value.next_hop.lz_key][value.next_hop.key].id, "") # Note the virtual_hub_connection must come from a remote tfstate only. PB with circular reference in the object model of vhub tables and connections
14: )
├────────────────
│ value.next_hop is object with 2 attributes
│ value.next_hop.resource_type is "azurerm_firewall"
│ var.remote_objects.azurerm_firewalls is object with 3 attributes
│ var.remote_objects.virtual_hub_connections is object with 3 attributes
│ var.resource_ids is object with 1 attribute "virtual_hub_connection"
Call to function "coalesce" failed: no non-null, non-empty-string arguments.
Terraform plan return code: 1
Hello guys,
I need to do something really simple: Create a new secret to a keyvault. The secret value must be randomly generated
I was hoping to do something as simple as that:
keyvaults.tfvars
random_strings = {
foo_password = {
length = 20
special = true
upper = true
number = true
}
}
dynamic_keyvault_secrets = {
kv = {
secret_key1 = {
secret_name = "foo_key"
value = foo_password.value
}
}
}
However, I don't think we can put any logic in tfvars files. It means that the logic must be placed somewhere else.
Do you have any recommendation ?
Hi. I finally have something working :-).
There's a gap between creating the launchpad and then creating level 2 resources.
I've used the CAF_TERRAFORM_LANDING_ZONES repository.
Running the level 100 launchpad shows no issues, however when running the Level 2 networking example (100-Single-Region-Hub), the command fails with an error about a NULL value for global_setting.regions.
In the end, it's to do with the content of the remote state file.
Level 1 is not populated with the 'Global_Settings' block in the Output section of the state file.
Running the level 1 Foundations doesn't work either as it seems to write to a different state file!
However, copying the Global_Settings block from the CAF_Solutions.tfstate to the caf_foundations.tfstate works!
I'm guessing therefore that there is a disconnect in the state files that the examples (scenarios) use which has thrown me?
Or have I missed something monumentally important?
Thanks
Hello there. I have been searching for documentation on this topic for a few hours, but have not been able to identify if what I am trying to do is something that the caf terraform module supports.
I am attempting to use subdirectory modules of https://github.com/aztfmod/terraform-azurerm-caf . Take for example trying to use the resource_group subdirectory module (aztfmod/caf/azurerm//modules/resource_group).
Is this something this module is intended to support the usage of?
# The code tries to peer to a vnet created in the same landing zone. If it fails it tries with the data remote state
resource "azurerm_virtual_network_peering" "peering" {
depends_on = [module.networking]
for_each = local.networking.vnet_peerings
name = azurecaf_name.peering[each.key].result
virtual_network_name = try(each.value.from.virtual_network_name, null) != null ? each.value.from.virtual_network_name : try(each.value.from.lz_key, null) == null ? try(local.combined_objects_networking[local.client_config.landingzone_key][each.value.from.vnet_key].name, null) : try(local.combined_objects_networking[each.value.from.lz_key][each.value.from.vnet_key].name, null)
resource_group_name = try(each.value.from.resource_group_name, null) != null ? each.value.from.resource_group_name : try(each.value.from.lz_key, null) == null ? try(local.combined_objects_networking[local.client_config.landingzone_key][each.value.from.vnet_key].resource_group_name, null) : try(local.combined_objects_networking[each.value.from.lz_key][each.value.from.vnet_key].resource_group_name, null)
remote_virtual_network_id = try(each.value.to.remote_virtual_network_id, null) != null ? each.value.to.remote_virtual_network_id : try(each.value.to.lz_key, null) == null ? try(local.combined_objects_networking[local.client_config.landingzone_key][each.value.to.vnet_key].id, null) : try(local.combined_objects_networking[each.value.to.lz_key][each.value.to.vnet_key].id, null)
allow_virtual_network_access = try(each.value.allow_virtual_network_access, true)
allow_forwarded_traffic = try(each.value.allow_forwarded_traffic, false)
allow_gateway_transit = try(each.value.allow_gateway_transit, false)
use_remote_gateways = try(each.value.use_remote_gateways, false)
}