-
Notifications
You must be signed in to change notification settings - Fork 708
Add azurecaf name
azurecaf_name
is used to format the resource names and ensure that they are compliant with the Azure naming restrictions. This provider also implements a set of methodologies for naming convention implementation including the default Microsoft Cloud Adoption Framework for Azure recommendations
An example of a resource that uses it is the aks
resource
resource "azurecaf_name" "aks" {
name = var.settings.name
resource_type = "azurerm_kubernetes_cluster"
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
}
The name is referenced in the name
attribute of the resource
resource "azurerm_kubernetes_cluster" "aks" {
name = azurecaf_name.aks.result
location = var.resource_group.location
resource_group_name = var.resource_group.name
This requires adding the aztfmod/azurecaf
provider to the main.tf
file
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
}
}
}
Sometimes the definition isn't defined especially if the resource was recently added by the azurerm
provider. To add a definition, refer to https://github.com/aztfmod/terraform-provider-azurecaf where there is a contributor guide that elaborates on how to add new definitions.