From 429e94efa95fd23af829de8af39a73df02548c9e Mon Sep 17 00:00:00 2001 From: Zidong Lu Date: Fri, 27 Sep 2024 14:55:02 +0800 Subject: [PATCH] Add more options to override the default values (#16) * change resource namespace to lower case * add more options to override the default value * fmt and doc --- README.md | 8 ++++++++ deploy.tf | 2 +- locals.tf | 6 +++--- main.tf | 6 +++--- validate.tf | 2 +- variables.tf | 6 ++++++ 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 04997bf..af119f5 100644 --- a/README.md +++ b/README.md @@ -540,6 +540,14 @@ Type: `string` Default: `"TLS1_2"` +### [naming\_prefix](#input\_naming\_prefix) + +Description: The naming prefix in HCI deployment settings. Site id will be used if not provided. + +Type: `string` + +Default: `""` + ### [operation\_type](#input\_operation\_type) Description: The intended operation for a cluster. diff --git a/deploy.tf b/deploy.tf index fe628fe..59566af 100644 --- a/deploy.tf +++ b/deploy.tf @@ -1,7 +1,7 @@ resource "azapi_update_resource" "deploymentsetting" { count = var.is_exported ? 0 : 1 - type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2024-04-01" + type = "microsoft.azurestackhci/clusters/deploymentSettings@2024-04-01" body = { properties = { deploymentMode = "Deploy" diff --git a/locals.tf b/locals.tf index 4a039f9..9503423 100644 --- a/locals.tf +++ b/locals.tf @@ -49,7 +49,7 @@ locals { storage = { configurationMode = var.configuration_mode } - namingPrefix = var.site_id + namingPrefix = var.naming_prefix == "" ? var.site_id : var.naming_prefix domainFqdn = var.domain_fqdn infrastructureNetwork = [{ useDhcp = false @@ -68,10 +68,10 @@ locals { enableStorageAutoIp = true intents = local.converged ? local.converged_intents : local.seperate_intents storageNetworks = local.storage_networks - storageConnectivitySwitchless = false + storageConnectivitySwitchless = var.storage_connectivity_switchless } adouPath = var.adou_path - secretsLocation = var.use_legacy_key_vault_model ? local.secrets_location : null + secretsLocation = var.use_legacy_key_vault_model ? local.secrets_location : (var.secrets_location == "" ? null : var.secrets_location) secrets = var.use_legacy_key_vault_model ? null : [ { secretName = "${var.name}-AzureStackLCMUserCredential" diff --git a/main.tf b/main.tf index 4a31fad..576b7c9 100644 --- a/main.tf +++ b/main.tf @@ -20,14 +20,14 @@ data "azapi_resource" "customlocation" { data "azapi_resource_list" "user_storages" { parent_id = data.azurerm_resource_group.rg.id - type = "Microsoft.AzureStackHCI/storagecontainers@2022-12-15-preview" + type = "microsoft.azurestackhci/storagecontainers@2022-12-15-preview" response_export_values = ["*"] depends_on = [azapi_update_resource.deploymentsetting] } data "azapi_resource" "arc_settings" { - type = "Microsoft.AzureStackHCI/clusters/ArcSettings@2024-04-01" + type = "microsoft.azurestackhci/clusters/ArcSettings@2024-04-01" name = "default" parent_id = azapi_resource.cluster.id @@ -35,7 +35,7 @@ data "azapi_resource" "arc_settings" { } resource "azapi_resource" "cluster" { - type = "Microsoft.AzureStackHCI/clusters@2024-04-01" + type = "microsoft.azurestackhci/clusters@2024-04-01" body = { properties = {} } diff --git a/validate.tf b/validate.tf index a4c39ed..66e6a3e 100644 --- a/validate.tf +++ b/validate.tf @@ -9,7 +9,7 @@ data "azurerm_arc_machine" "arcservers" { } resource "azapi_resource" "validatedeploymentsetting" { - type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2024-04-01" + type = "microsoft.azurestackhci/clusters/deploymentSettings@2024-04-01" body = { properties = local.deployment_setting_properties_omit_null } diff --git a/variables.tf b/variables.tf index ee3b6fd..61ab681 100644 --- a/variables.tf +++ b/variables.tf @@ -388,6 +388,12 @@ variable "min_tls_version" { description = "The minimum TLS version." } +variable "naming_prefix" { + type = string + default = "" + description = "The naming prefix in HCI deployment settings. Site id will be used if not provided." +} + variable "operation_type" { type = string default = "ClusterProvisioning"