Closed d0ru closed 1 year ago
Hi @d0ru thanks for opening this issue, I personally prefer a loose coupling style for this module, so we don't need to make the default values follow the naming module's style, but we can make sure that all resources' names could be set by the module's callers.
Are you interested in opening some prs to make that happen? e.g., for public ip resources?
I would really enjoy having the possibility of setting the naming convention to a specific pattern. From my experience there are a lot of different use cases for naming and enterprises all have their own naming convention. Using the recommendation from Microsoft in the CAF framework could be the default one but having the option to add some custom patterns.
It is not the most elegant code, but it explains the thought. Using this will result in 7!=5040 possible patterns to use. Of course this can be changes and renamed. Example:
locals {
resourcename = replace(replace(replace(replace(replace(replace(replace(
var.pattern,"{customer}",var.customer),
"{area}",var.area),
"{applicationsystem}",var.applicationsystem),
"{region}",var.region),
"{resourcetype}",var.resourcetype),
"{environment}",var.environment),
"{counter}",var.counter)
}
variable "pattern" {
type = string
default = "{customer}-{area}{applicationsystem}-{region}-{resourcetype}-{environment}"
}
Changing the pattern input will result in different naming conventions and then the users are free to use whatever they want. Put this into a simple module and use if for creating names could be a solution to consider.
This could also just be a recommendation that is put outside of the module and then the module can have the possibility of inputting the names of every resource. But I think it is easier for the end user to just define a custom naming pattern and then the entire module fixes it.
Hi @hlokensgard
After discussion we feel that the naming modules/providers belong outside this module. We will provide an example of how to do this.
We recommend using https://registry.terraform.io/modules/Azure/naming/azurerm/latest
Is there an existing issue for this?
Description
According with Terraform Registry stats,
Azure/naming/azurerm
is the most popular Azure module. Thus, it makes sense to expect that all Azure modules are following the recommended naming conventions implemented by this module.I've tried to overwrite some of the defaults and sometimes it works, for others it's not (ie. public_ip). If the default naming is respected it will cover most needs to override the resource names.
Thanks
New or Affected Resource(s)/Data Source(s)
azurerm
Potential Terraform Configuration
No response
References
https://github.com/Azure/terraform-azurerm-naming