aztfmod / terraform-provider-azurecaf

Terraform provider for the Terraform platform engineering for Azure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent results for similar usage of module

Kumar9676 opened this issue · comments

Below is the code for Azure CAF that I am using to create resources. I want to use CAF to generate two names for storage account as follows -
Expected Output -
cistmartechapacuc01sandbox
cistmartechapacapp01sandbox

Generated Output -
cistmartechapacapp01
stmartechapacuc01sandbox

The outputs are not consistent while I am using same code.

`variable "name_prefix" {
description = "Project environment"
type = string
default = "ci"
}

variable "location_short" {
description = "Resource region"
type = string
default = ""
}

variable "name_suffix" {
description = "Resource region"
type = string
default = ""
}

variable "use_caf_naming" {
description = "Resource region"
type = bool
default = true
}

variable "environment" {
description = "Project environment"
type = string
default = "sandbox"
}

variable "stack" {
description = "Project stack name"
type = string
default = "martech"
}

data "azurecaf_name" "sa" {
name = var.stack
resource_type = "azurerm_storage_account"
prefixes = var.name_prefix == "" ? null : [var.name_prefix]
suffixes = compact(["apac-app-01", var.location_short, var.environment, var.name_suffix, var.use_caf_naming ? "" : "sa"])
use_slug = var.use_caf_naming
clean_input = true
separator = "-"
}

data "azurecaf_name" "sauc" {
name = var.stack
resource_type = "azurerm_storage_account"
prefixes = var.name_prefix == "" ? null : [var.name_prefix]
suffixes = compact(["apac-uc-01", var.location_short, var.environment, var.name_suffix, var.use_caf_naming ? "" : "sa"])
use_slug = var.use_caf_naming
clean_input = true
separator = "-"
}

resource "azurerm_storage_account" "demo" {
name = data.azurecaf_name.sa.result
location = "southeastasia"
resource_group_name = module.rg.resource_group_name
account_tier = "Standard"
account_replication_type = "LRS"
}
Generated Output - cistmartechapacapp01

resource "azurerm_storage_account" "demo2" {
name = data.azurecaf_name.sauc.result
location = "southeastasia"
resource_group_name = module.rg.resource_group_name
account_tier = "Standard"
account_replication_type = "LRS"
}`
Generated Output - stmartechapacuc01sandbox

Provider Config -
terraform {
required_version = ">= 1.3.7"

}
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.31.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.0"
}
azurecaf = {
source = "aztfmod/azurecaf"
version = "2.0.0-preview3"
}
}
}