Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent results for similar usage of module #265

Open
Kumar9676 opened this issue Dec 6, 2023 · 0 comments
Open

Inconsistent results for similar usage of module #265

Kumar9676 opened this issue Dec 6, 2023 · 0 comments

Comments

@Kumar9676
Copy link

Kumar9676 commented Dec 6, 2023

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"
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant