terraform-provider-azurecaf
terraform-provider-azurecaf copied to clipboard
r/azurecaf_name: random_length is not working as documented
To make random_length property to work, one should calculate the difference between max characters available for the resource and all other higher priority items like slug, name, prefixes, suffixes. random_length should be set to that diff number or less, otherwise - it will be ignored from the name at all which makes no sense.
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
version = "~> 1.0"
}
}
}
resource "azurecaf_name" "example" {
name = "00000"
random_length = 50
resource_type = "azurerm_storage_account"
}
output "test" {
value = azurecaf_name.example.result
}
Expected: Value extended with random characters up to the max available count (24 for storage account).
st00000kwtfv13g90nvqwi29
Actual:
Outputs:
test = st00000
Totally agree on this!
My use case is very similar, I'm doing:
resource "azurecaf_name" "key_vault" {
name = var.application_name
resource_type = "azurerm_key_vault"
suffixes = ["dev"]
}
And if my application name is too big, instead of having:
kvabcdefghijklmnopqrsdev
(using the kv
prefix and dev
suffix)
I'm having:
kvdev
@Nepomuceno any chance you can have a look on this one? :)
This is related to #24 it is interesting to think about how this should actually work. Will put some options so you can have freedon to control how the truncate happens in these cases makes sense to change this the way that it is working it is not ideal but at the same time questions if the random lengh it is too long but the suffix it is not should I cutr the random and include as most of it as I can or should I cut it entirely and try to insert the postfix. Or shoudl I actually give an eerror when trying to generate a name that si bigger than the max name size.
bump. any update on this @Nepomuceno?