The following error is observed in terraform plan.
╷
│ Error: Reference to "each" in context without for_each
│
│ on .terraform/modules/terraform_azurerm_avm_res_compute_virtualmachinescaleset/main.tf line 183, in resource "azurerm_orchestrated_virtual_machine_scale_set" "virtual_machine_scale_set":
│ 183: public_key = var.admin_ssh_keys[each.key].public_key
│
│ The "each" object can be used only in "module" or "resource" blocks, and only when the "for_each" argument is set.
╵
╷
│ Error: Reference to "each" in context without for_each
│
│ on .terraform/modules/terraform_azurerm_avm_res_compute_virtualmachinescaleset/main.tf line 184, in resource "azurerm_orchestrated_virtual_machine_scale_set" "virtual_machine_scale_set":
│ 184: username = var.admin_ssh_keys[each.key].username
│
│ The "each" object can be used only in "module" or "resource" blocks, and only when the "for_each" argument is set.
Check for previous/existing GitHub issues
Issue Type?
Bug
(Optional) Module Version
No response
(Optional) Correlation Id
No response
Description
The code to produce this is similar to the examples in the module. Partial snippet below.
The following error is observed in terraform plan.
Please see if https://github.com/Azure/terraform-azurerm-avm-res-compute-virtualmachinescaleset/compare/main...chianw:terraform-azurerm-avm-res-compute-virtualmachinescaleset:main addresses this or if this is a bug at all?