aztfmod / terraform-azurerm-caf

Terraform supermodule for the Terraform platform engineering for Azure
https://aztfmod.github.io/documentation/
MIT License
560 stars 704 forks source link

Allow appending random numbers to CosmosDB database names to be optional #940

Open brianfedorcrowe opened 2 years ago

brianfedorcrowe commented 2 years ago

The CosmosDB databases we deploy do not need unique naming to be enforced by appending a random 5-digit number to their names. We need the names specified in our tfvars to be unaltered, which is not possible due to the random-generated number being appended by the module as shown below.

https://github.com/aztfmod/terraform-azurerm-caf/blob/main/modules/databases/cosmos_dbs/sql_database/sql_database.tf#L10

# Create database
resource "azurerm_cosmosdb_sql_database" "database" {
  name                = format("%s-%s", var.settings.name, random_integer.ri.result)

Instead, we would prefer this behavior to be optional, whereby we can indicate whether or not to append random-generated numbers to the database names. This could be achieved by introducing a new boolean flag that can be set in the tfvars for the resource. Then, some type of conditional logic within the module would handle constructing the database name value based upon the value of the flag.

arnaudlh commented 2 years ago

hi @brianfedorcrowe agree with you it's not optimal and should use the naming provider to respect the framework behavior. let's assess the work needed and plan for it. cc @SergioMiyama

brianfedorcrowe commented 2 years ago

Thank you for taking this into consideration and offering to devise a way to address it. Is there anything I can do to help foster this along?

brianfedorcrowe commented 2 years ago

Our organization is not yet in a position to contribute to public repos in GitHub. Otherwise we would propose a solution via a PR for this. This issue is preventing us from being able to use the CAF Terraform module for Cosmos DB at this time. Since this was tagged as a "Bug", will it be slated for the current milestone or the next.