will returns this error if var.keycloak_enabled=false:
│ on main.tf line 133, in locals:
│ 133: key_name = module.key_pair[0].key_pair_name
│ ├────────────────
│ │ module.key_pair is empty tuple
│
│ The given key does not identify an element in this collection value: the collection has no elements.
A possible fix is replacing key_name = module.key_pair[0].key_pair_name with key_name = var.keycloak_enabled ? module.key_pair[0].key_pair_name : null.
Completion
Completion of this issue would be the ability to deploy the example with var.keycloak_enabled=false.
Expanding this issue to include adding a e2e test for validating that variables (currently just kecloak_enabled, but could easily be extended to include others) work when both true/false empty/full.
Description
Because the Keycloak key is enabled or disabled based on a count, this statement:
will returns this error if
var.keycloak_enabled=false
:A possible fix is replacing
key_name = module.key_pair[0].key_pair_name
withkey_name = var.keycloak_enabled ? module.key_pair[0].key_pair_name : null
.Completion
Completion of this issue would be the ability to deploy the example with
var.keycloak_enabled=false
.