diff --git a/.terraform-docs.yml b/.terraform-docs.yml index 0587077..e844eb2 100644 --- a/.terraform-docs.yml +++ b/.terraform-docs.yml @@ -4,7 +4,7 @@ formatter: "markdown document" # this is required -version: "~> 0.17.0" +version: "~> 0.18.0" header-from: "_header.md" footer-from: "_footer.md" diff --git a/README.md b/README.md index 0e62aeb..4c39071 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,7 @@ -# terraform-azurerm-avm-template +# terraform-azurerm-avm-res-azurestackhci-cluster -This is a template repo for Terraform Azure Verified Modules. - -Things to do: - -1. Set up a GitHub repo environment called `test`. -1. Configure environment protection rule to ensure that approval is required before deploying to this environment. -1. Install Docker Desktop to run tests +Module to provision azure stack hci. > [!IMPORTANT] > As the overall AVM framework is not GA (generally available) yet - the CI framework and test automation is not fully functional and implemented across all supported languages yet - breaking changes are expected, and additional customer feedback is yet to be gathered and incorporated. Hence, modules **MUST NOT** be published at version `1.0.0` or higher at this time. @@ -23,35 +17,45 @@ The following requirements are needed by this module: - [terraform](#requirement\_terraform) (~> 1.5) +- [azapi](#requirement\_azapi) (~> 1.14) + +- [azuread](#requirement\_azuread) (~> 2.50.0) + - [azurerm](#requirement\_azurerm) (~> 3.71) - [modtm](#requirement\_modtm) (~> 0.3) - [random](#requirement\_random) (~> 3.5) -## Providers - -The following providers are used by this module: - -- [azurerm](#provider\_azurerm) (~> 3.71) - -- [modtm](#provider\_modtm) (~> 0.3) - -- [random](#provider\_random) (~> 3.5) - ## Resources The following resources are used by this module: +- [azapi_resource.cluster](https://registry.terraform.io/providers/azure/azapi/latest/docs/resources/resource) (resource) +- [azapi_resource.validatedeploymentsetting](https://registry.terraform.io/providers/azure/azapi/latest/docs/resources/resource) (resource) +- [azapi_resource.validatedeploymentsetting_seperate](https://registry.terraform.io/providers/azure/azapi/latest/docs/resources/resource) (resource) +- [azapi_update_resource.deploymentsetting](https://registry.terraform.io/providers/azure/azapi/latest/docs/resources/update_resource) (resource) +- [azurerm_key_vault.deployment_keyvault](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault) (resource) +- [azurerm_key_vault_secret.azure_stack_lcm_user_credential](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource) +- [azurerm_key_vault_secret.default_arb_application](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource) +- [azurerm_key_vault_secret.local_admin_credential](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource) +- [azurerm_key_vault_secret.witness_storage_key](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource) - [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource) -- [azurerm_private_endpoint.this_managed_dns_zone_groups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource) -- [azurerm_private_endpoint.this_unmanaged_dns_zone_groups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource) -- [azurerm_private_endpoint_application_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint_application_security_group_association) (resource) -- [azurerm_resource_group.TODO](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource) +- [azurerm_role_assignment.service_principal_role_assign](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource) - [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource) +- [azurerm_storage_account.witness](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account) (resource) - [modtm_telemetry.telemetry](https://registry.terraform.io/providers/azure/modtm/latest/docs/resources/telemetry) (resource) +- [random_integer.random_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource) - [random_uuid.telemetry](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) (resource) +- [azapi_resource.arc_settings](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource) (data source) +- [azapi_resource.arcbridge](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource) (data source) +- [azapi_resource.customlocation](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource) (data source) +- [azapi_resource_list.user_storages](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource_list) (data source) +- [azuread_service_principal.hci_rp](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/service_principal) (data source) +- [azurerm_arc_machine.arcservers](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/arc_machine) (data source) +- [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source) - [azurerm_client_config.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source) +- [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source) - [modtm_module_source.telemetry](https://registry.terraform.io/providers/azure/modtm/latest/docs/data-sources/module_source) (data source) @@ -59,85 +63,168 @@ The following resources are used by this module: The following input variables are required: +### [adou\_path](#input\_adou\_path) + +Description: The Active Directory OU path. + +Type: `string` + +### [custom\_location\_name](#input\_custom\_location\_name) + +Description: The name of the custom location. + +Type: `string` + +### [default\_gateway](#input\_default\_gateway) + +Description: The default gateway for the network. + +Type: `string` + +### [deployment\_user](#input\_deployment\_user) + +Description: The username for the domain administrator account. + +Type: `string` + +### [deployment\_user\_password](#input\_deployment\_user\_password) + +Description: The password for the domain administrator account. + +Type: `string` + +### [dns\_servers](#input\_dns\_servers) + +Description: A list of DNS server IP addresses. + +Type: `list(string)` + +### [domain\_fqdn](#input\_domain\_fqdn) + +Description: The domain FQDN. + +Type: `string` + +### [ending\_address](#input\_ending\_address) + +Description: The ending IP address of the IP address range. + +Type: `string` + +### [keyvault\_name](#input\_keyvault\_name) + +Description: The name of the key vault. + +Type: `string` + +### [local\_admin\_password](#input\_local\_admin\_password) + +Description: The password for the local administrator account. + +Type: `string` + +### [local\_admin\_user](#input\_local\_admin\_user) + +Description: The username for the local administrator account. + +Type: `string` + ### [location](#input\_location) Description: Azure region where the resource should be deployed. Type: `string` +### [management\_adapters](#input\_management\_adapters) + +Description: A list of management adapters. + +Type: `list(string)` + ### [name](#input\_name) -Description: The name of the this resource. +Description: The name of the HCI cluster. Must be the same as the name when preparing AD. Type: `string` +### [rdma\_enabled](#input\_rdma\_enabled) + +Description: Indicates whether RDMA is enabled. + +Type: `bool` + ### [resource\_group\_name](#input\_resource\_group\_name) Description: The resource group where the resources will be deployed. Type: `string` -## Optional Inputs - -The following input variables are optional (have default values): - -### [customer\_managed\_key](#input\_customer\_managed\_key) +### [servers](#input\_servers) -Description: A map describing customer-managed keys to associate with the resource. This includes the following properties: -- `key_vault_resource_id` - The resource ID of the Key Vault where the key is stored. -- `key_name` - The name of the key. -- `key_version` - (Optional) The version of the key. If not specified, the latest version is used. -- `user_assigned_identity` - (Optional) An object representing a user-assigned identity with the following properties: - - `resource_id` - The resource ID of the user-assigned identity. +Description: A list of servers with their names and IPv4 addresses. Type: ```hcl -object({ - key_vault_resource_id = string - key_name = string - key_version = optional(string, null) - user_assigned_identity = optional(object({ - resource_id = string - }), null) - }) +list(object({ + name = string + ipv4Address = string + })) ``` -Default: `null` +### [service\_principal\_id](#input\_service\_principal\_id) + +Description: The service principal ID for the Azure account. + +Type: `string` + +### [service\_principal\_secret](#input\_service\_principal\_secret) + +Description: The service principal secret for the Azure account. -### [diagnostic\_settings](#input\_diagnostic\_settings) +Type: `string` + +### [site\_id](#input\_site\_id) + +Description: A unique identifier for the site. + +Type: `string` + +### [starting\_address](#input\_starting\_address) + +Description: The starting IP address of the IP address range. + +Type: `string` -Description: A map of diagnostic settings to create on the Key Vault. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time. +### [storage\_connectivity\_switchless](#input\_storage\_connectivity\_switchless) -- `name` - (Optional) The name of the diagnostic setting. One will be generated if not set, however this will not be unique if you want to create multiple diagnostic setting resources. -- `log_categories` - (Optional) A set of log categories to send to the log analytics workspace. Defaults to `[]`. -- `log_groups` - (Optional) A set of log groups to send to the log analytics workspace. Defaults to `["allLogs"]`. -- `metric_categories` - (Optional) A set of metric categories to send to the log analytics workspace. Defaults to `["AllMetrics"]`. -- `log_analytics_destination_type` - (Optional) The destination type for the diagnostic setting. Possible values are `Dedicated` and `AzureDiagnostics`. Defaults to `Dedicated`. -- `workspace_resource_id` - (Optional) The resource ID of the log analytics workspace to send logs and metrics to. -- `storage_account_resource_id` - (Optional) The resource ID of the storage account to send logs and metrics to. -- `event_hub_authorization_rule_resource_id` - (Optional) The resource ID of the event hub authorization rule to send logs and metrics to. -- `event_hub_name` - (Optional) The name of the event hub. If none is specified, the default event hub will be selected. -- `marketplace_partner_resource_id` - (Optional) The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic LogsLogs. +Description: Indicates whether storage connectivity is switchless. + +Type: `bool` + +### [storage\_networks](#input\_storage\_networks) + +Description: A list of storage networks. Type: ```hcl -map(object({ - name = optional(string, null) - log_categories = optional(set(string), []) - log_groups = optional(set(string), ["allLogs"]) - metric_categories = optional(set(string), ["AllMetrics"]) - log_analytics_destination_type = optional(string, "Dedicated") - workspace_resource_id = optional(string, null) - storage_account_resource_id = optional(string, null) - event_hub_authorization_rule_resource_id = optional(string, null) - event_hub_name = optional(string, null) - marketplace_partner_resource_id = optional(string, null) +list(object({ + name = string + networkAdapterName = string + vlanId = string })) ``` -Default: `{}` +### [witness\_storage\_account\_name](#input\_witness\_storage\_account\_name) + +Description: The name of the witness storage account. + +Type: `string` + +## Optional Inputs + +The following input variables are optional (have default values): ### [enable\_telemetry](#input\_enable\_telemetry) @@ -149,6 +236,14 @@ Type: `bool` Default: `true` +### [is\_exported](#input\_is\_exported) + +Description: Indicate whether the resource is exported + +Type: `bool` + +Default: `false` + ### [lock](#input\_lock) Description: Controls the Resource Lock configuration for this resource. The following properties can be specified: @@ -167,83 +262,9 @@ object({ Default: `null` -### [managed\_identities](#input\_managed\_identities) - -Description: Controls the Managed Identity configuration on this resource. The following properties can be specified: - -- `system_assigned` - (Optional) Specifies if the System Assigned Managed Identity should be enabled. -- `user_assigned_resource_ids` - (Optional) Specifies a list of User Assigned Managed Identity resource IDs to be assigned to this resource. - -Type: - -```hcl -object({ - system_assigned = optional(bool, false) - user_assigned_resource_ids = optional(set(string), []) - }) -``` - -Default: `{}` - -### [private\_endpoints](#input\_private\_endpoints) - -Description: A map of private endpoints to create on this resource. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time. - -- `name` - (Optional) The name of the private endpoint. One will be generated if not set. -- `role_assignments` - (Optional) A map of role assignments to create on the private endpoint. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time. See `var.role_assignments` for more information. -- `lock` - (Optional) The lock level to apply to the private endpoint. Default is `None`. Possible values are `None`, `CanNotDelete`, and `ReadOnly`. -- `tags` - (Optional) A mapping of tags to assign to the private endpoint. -- `subnet_resource_id` - The resource ID of the subnet to deploy the private endpoint in. -- `private_dns_zone_group_name` - (Optional) The name of the private DNS zone group. One will be generated if not set. -- `private_dns_zone_resource_ids` - (Optional) A set of resource IDs of private DNS zones to associate with the private endpoint. If not set, no zone groups will be created and the private endpoint will not be associated with any private DNS zones. DNS records must be managed external to this module. -- `application_security_group_resource_ids` - (Optional) A map of resource IDs of application security groups to associate with the private endpoint. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time. -- `private_service_connection_name` - (Optional) The name of the private service connection. One will be generated if not set. -- `network_interface_name` - (Optional) The name of the network interface. One will be generated if not set. -- `location` - (Optional) The Azure location where the resources will be deployed. Defaults to the location of the resource group. -- `resource_group_name` - (Optional) The resource group where the resources will be deployed. Defaults to the resource group of this resource. -- `ip_configurations` - (Optional) A map of IP configurations to create on the private endpoint. If not specified the platform will create one. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time. - - `name` - The name of the IP configuration. - - `private_ip_address` - The private IP address of the IP configuration. - -Type: - -```hcl -map(object({ - name = optional(string, null) - role_assignments = optional(map(object({ - role_definition_id_or_name = string - principal_id = string - description = optional(string, null) - skip_service_principal_aad_check = optional(bool, false) - condition = optional(string, null) - condition_version = optional(string, null) - delegated_managed_identity_resource_id = optional(string, null) - })), {}) - lock = optional(object({ - kind = string - name = optional(string, null) - }), null) - tags = optional(map(string), null) - subnet_resource_id = string - private_dns_zone_group_name = optional(string, "default") - private_dns_zone_resource_ids = optional(set(string), []) - application_security_group_associations = optional(map(string), {}) - private_service_connection_name = optional(string, null) - network_interface_name = optional(string, null) - location = optional(string, null) - resource_group_name = optional(string, null) - ip_configurations = optional(map(object({ - name = string - private_ip_address = string - })), {}) - })) -``` - -Default: `{}` - -### [private\_endpoints\_manage\_dns\_zone\_group](#input\_private\_endpoints\_manage\_dns\_zone\_group) +### [random\_suffix](#input\_random\_suffix) -Description: Whether to manage private DNS zone groups with this module. If set to false, you must manage private DNS zone groups externally, e.g. using Azure Policy. +Description: Indicate whether to add random suffix Type: `bool` @@ -273,11 +294,28 @@ map(object({ condition = optional(string, null) condition_version = optional(string, null) delegated_managed_identity_resource_id = optional(string, null) + principal_type = optional(string, null) })) ``` Default: `{}` +### [rp\_service\_principal\_object\_id](#input\_rp\_service\_principal\_object\_id) + +Description: The object ID of the HCI resource provider service principal. + +Type: `string` + +Default: `""` + +### [subnet\_mask](#input\_subnet\_mask) + +Description: The subnet mask for the network. + +Type: `string` + +Default: `"255.255.255.0"` + ### [tags](#input\_tags) Description: (Optional) Tags of the resource. @@ -290,14 +328,38 @@ Default: `null` The following outputs are exported: -### [private\_endpoints](#output\_private\_endpoints) +### [arc\_settings](#output\_arc\_settings) + +Description: Arc settings instance after HCI connected. + +### [arcbridge](#output\_arcbridge) + +Description: Arc resource bridge instance after HCI connected. -Description: A map of the private endpoints created. +### [cluster](#output\_cluster) -### [resource](#output\_resource) +Description: HCI Cluster instance + +### [customlocation](#output\_customlocation) + +Description: Custom location instance after HCI connected. + +### [keyvault](#output\_keyvault) + +Description: Keyvault instance that stores deployment secrets. + +### [resource\_id](#output\_resource\_id) Description: This is the full output for the resource. +### [user\_storages](#output\_user\_storages) + +Description: User storage instances after HCI connected. + +### [v\_switch\_name](#output\_v\_switch\_name) + +Description: The name of the virtual switch that is used by the network. + ## Modules No modules. @@ -306,4 +368,4 @@ No modules. ## Data Collection The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at . You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices. - + \ No newline at end of file diff --git a/_header.md b/_header.md index 518d2f6..1a27b3a 100644 --- a/_header.md +++ b/_header.md @@ -1,15 +1,6 @@ -# terraform-azurerm-avm-template +# terraform-azurerm-avm-res-azurestackhci-cluster -This is a template repo for Terraform Azure Verified Modules. - -Things to do: - -1. Set up a GitHub repo environment called `test`. -1. Configure environment protection rule to ensure that approval is required before deploying to this environment. -1. Create a user-assigned managed identity in your test subscription. -1. Create a role assignment for the managed identity on your test subscription, use the minimum required role. -1. Configure federated identity credentials on the user assigned managed identity. Use the GitHub environment. -1. Search and update TODOs within the code and remove the TODO comments once complete. +Module to provision azure stack hci. > [!IMPORTANT] > As the overall AVM framework is not GA (generally available) yet - the CI framework and test automation is not fully functional and implemented across all supported languages yet - breaking changes are expected, and additional customer feedback is yet to be gathered and incorporated. Hence, modules **MUST NOT** be published at version `1.0.0` or higher at this time. diff --git a/deploy.tf b/deploy.tf new file mode 100644 index 0000000..30b4485 --- /dev/null +++ b/deploy.tf @@ -0,0 +1,19 @@ +resource "azapi_update_resource" "deploymentsetting" { + count = var.is_exported ? 0 : 1 + + type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2023-08-01-preview" + body = { + properties = { + deploymentMode = "Deploy" + } + } + name = "default" + parent_id = azapi_resource.cluster.id + + timeouts { + create = "24h" + delete = "60m" + } + + depends_on = [azapi_resource.validatedeploymentsetting, azapi_resource.validatedeploymentsetting_seperate] +} diff --git a/examples/.terraform-docs.yml b/examples/.terraform-docs.yml index a95ea42..a07d346 100644 --- a/examples/.terraform-docs.yml +++ b/examples/.terraform-docs.yml @@ -4,7 +4,7 @@ formatter: "markdown document" # this is required -version: "~> 0.17.0" +version: "~> 0.18.0" header-from: "_header.md" footer-from: "_footer.md" diff --git a/examples/default/README.md b/examples/default/README.md index f103557..3c16ee7 100644 --- a/examples/default/README.md +++ b/examples/default/README.md @@ -11,10 +11,6 @@ terraform { source = "hashicorp/azurerm" version = "~> 3.74" } - modtm = { - source = "azure/modtm" - version = "~> 0.3" - } random = { source = "hashicorp/random" version = "~> 3.5" @@ -23,7 +19,11 @@ terraform { } provider "azurerm" { - features {} + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } } @@ -47,10 +47,8 @@ module "naming" { version = "~> 0.3" } -# This is required for resource modules -resource "azurerm_resource_group" "this" { - location = module.regions.regions[random_integer.region_index.result].name - name = module.naming.resource_group.name_unique +data "azurerm_resource_group" "rg" { + name = var.resource_group_name } # This is the module call @@ -59,13 +57,58 @@ resource "azurerm_resource_group" "this" { # with a data source. module "test" { source = "../../" - # source = "Azure/avm--/azurerm" + # source = "Azure/avm-res-azurestackhci-cluster/azurerm" # ... - location = azurerm_resource_group.this.location - name = "TODO" # TODO update with module.naming..name_unique - resource_group_name = azurerm_resource_group.this.name + location = data.azurerm_resource_group.rg.location + name = local.name # TODO update with module.naming..name_unique + resource_group_name = data.azurerm_resource_group.rg.name enable_telemetry = var.enable_telemetry # see variables.tf + + site_id = var.site_id + domain_fqdn = "jumpstart.local" + starting_address = "192.168.1.55" + ending_address = "192.168.1.65" + subnet_mask = var.subnet_mask + default_gateway = "192.168.1.1" + dns_servers = ["192.168.1.254"] + adou_path = local.adou_path + servers = [ + { + name = "AzSHOST1", + ipv4Address = "192.168.1.12" + }, + { + name = "AzSHOST2", + ipv4Address = "192.168.1.13" + } + ] + management_adapters = ["FABRIC", "FABRIC2"] + storage_networks = [ + { + name = "Storage1Network", + networkAdapterName = "StorageA", + vlanId = "711" + }, + { + name = "Storage2Network", + networkAdapterName = "StorageB", + vlanId = "712" + } + ] + rdma_enabled = false + storage_connectivity_switchless = false + custom_location_name = local.custom_location_name + witness_storage_account_name = local.witness_storage_account_name + keyvault_name = local.keyvault_name + random_suffix = true + deployment_user = var.deployment_user + deployment_user_password = var.deployment_user_password + local_admin_user = var.local_admin_user + local_admin_password = var.local_admin_password + service_principal_id = var.service_principal_id + service_principal_secret = var.service_principal_secret + rp_service_principal_object_id = var.rp_service_principal_object_id } ``` @@ -78,34 +121,82 @@ The following requirements are needed by this module: - [azurerm](#requirement\_azurerm) (~> 3.74) -- [modtm](#requirement\_modtm) (~> 0.3) - - [random](#requirement\_random) (~> 3.5) -## Providers - -The following providers are used by this module: - -- [azurerm](#provider\_azurerm) (~> 3.74) - -- [random](#provider\_random) (~> 3.5) - ## Resources The following resources are used by this module: -- [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource) - [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource) +- [azurerm_resource_group.rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source) ## Required Inputs -No required inputs. +The following input variables are required: + +### [deployment\_user\_password](#input\_deployment\_user\_password) + +Description: The password for deployment user. + +Type: `string` + +### [local\_admin\_password](#input\_local\_admin\_password) + +Description: The password for the local administrator account. + +Type: `string` + +### [local\_admin\_user](#input\_local\_admin\_user) + +Description: The username for the local administrator account. + +Type: `string` + +### [resource\_group\_name](#input\_resource\_group\_name) + +Description: The resource group where the resources will be deployed. + +Type: `string` + +### [service\_principal\_id](#input\_service\_principal\_id) + +Description: The service principal ID for ARB. + +Type: `string` + +### [service\_principal\_secret](#input\_service\_principal\_secret) + +Description: The service principal secret. + +Type: `string` + +### [site\_id](#input\_site\_id) + +Description: A unique identifier for the site. + +Type: `string` ## Optional Inputs The following input variables are optional (have default values): +### [adou\_suffix](#input\_adou\_suffix) + +Description: The suffix of Active Directory OU path. + +Type: `string` + +Default: `"DC=jumpstart,DC=local"` + +### [deployment\_user](#input\_deployment\_user) + +Description: The username for deployment user. + +Type: `string` + +Default: `"avmdeploy"` + ### [enable\_telemetry](#input\_enable\_telemetry) Description: This variable controls whether or not telemetry is enabled for the module. @@ -116,6 +207,22 @@ Type: `bool` Default: `true` +### [rp\_service\_principal\_object\_id](#input\_rp\_service\_principal\_object\_id) + +Description: The object ID of the HCI resource provider service principal. + +Type: `string` + +Default: `""` + +### [subnet\_mask](#input\_subnet\_mask) + +Description: The subnet mask for the network. + +Type: `string` + +Default: `"255.255.255.0"` + ## Outputs No outputs. diff --git a/examples/default/locals.tf b/examples/default/locals.tf new file mode 100644 index 0000000..5bb86d1 --- /dev/null +++ b/examples/default/locals.tf @@ -0,0 +1,7 @@ +locals { + adou_path = "OU=${var.resource_group_name},${var.adou_suffix}" + custom_location_name = "customlocation-${var.site_id}" + keyvault_name = "kv${var.site_id}" + name = "cl${var.site_id}" + witness_storage_account_name = "${lower(var.site_id)}wit" +} diff --git a/examples/default/main.tf b/examples/default/main.tf index 39a64f3..8982a95 100644 --- a/examples/default/main.tf +++ b/examples/default/main.tf @@ -5,10 +5,6 @@ terraform { source = "hashicorp/azurerm" version = "~> 3.74" } - modtm = { - source = "azure/modtm" - version = "~> 0.3" - } random = { source = "hashicorp/random" version = "~> 3.5" @@ -17,7 +13,11 @@ terraform { } provider "azurerm" { - features {} + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + } } @@ -41,10 +41,8 @@ module "naming" { version = "~> 0.3" } -# This is required for resource modules -resource "azurerm_resource_group" "this" { - location = module.regions.regions[random_integer.region_index.result].name - name = module.naming.resource_group.name_unique +data "azurerm_resource_group" "rg" { + name = var.resource_group_name } # This is the module call @@ -53,11 +51,56 @@ resource "azurerm_resource_group" "this" { # with a data source. module "test" { source = "../../" - # source = "Azure/avm--/azurerm" + # source = "Azure/avm-res-azurestackhci-cluster/azurerm" # ... - location = azurerm_resource_group.this.location - name = "TODO" # TODO update with module.naming..name_unique - resource_group_name = azurerm_resource_group.this.name + location = data.azurerm_resource_group.rg.location + name = local.name # TODO update with module.naming..name_unique + resource_group_name = data.azurerm_resource_group.rg.name enable_telemetry = var.enable_telemetry # see variables.tf + + site_id = var.site_id + domain_fqdn = "jumpstart.local" + starting_address = "192.168.1.55" + ending_address = "192.168.1.65" + subnet_mask = var.subnet_mask + default_gateway = "192.168.1.1" + dns_servers = ["192.168.1.254"] + adou_path = local.adou_path + servers = [ + { + name = "AzSHOST1", + ipv4Address = "192.168.1.12" + }, + { + name = "AzSHOST2", + ipv4Address = "192.168.1.13" + } + ] + management_adapters = ["FABRIC", "FABRIC2"] + storage_networks = [ + { + name = "Storage1Network", + networkAdapterName = "StorageA", + vlanId = "711" + }, + { + name = "Storage2Network", + networkAdapterName = "StorageB", + vlanId = "712" + } + ] + rdma_enabled = false + storage_connectivity_switchless = false + custom_location_name = local.custom_location_name + witness_storage_account_name = local.witness_storage_account_name + keyvault_name = local.keyvault_name + random_suffix = true + deployment_user = var.deployment_user + deployment_user_password = var.deployment_user_password + local_admin_user = var.local_admin_user + local_admin_password = var.local_admin_password + service_principal_id = var.service_principal_id + service_principal_secret = var.service_principal_secret + rp_service_principal_object_id = var.rp_service_principal_object_id } diff --git a/examples/default/variables.tf b/examples/default/variables.tf index e52bbd6..3f2c0fc 100644 --- a/examples/default/variables.tf +++ b/examples/default/variables.tf @@ -1,3 +1,52 @@ +variable "deployment_user_password" { + type = string + description = "The password for deployment user." + sensitive = true +} + +variable "local_admin_password" { + type = string + description = "The password for the local administrator account." + sensitive = true +} + +variable "local_admin_user" { + type = string + description = "The username for the local administrator account." +} + +variable "resource_group_name" { + type = string + description = "The resource group where the resources will be deployed." +} + +variable "service_principal_id" { + type = string + description = "The service principal ID for ARB." +} + +variable "service_principal_secret" { + type = string + description = "The service principal secret." +} + +variable "site_id" { + type = string + description = "A unique identifier for the site." +} + +variable "adou_suffix" { + type = string + default = "DC=jumpstart,DC=local" + description = "The suffix of Active Directory OU path." +} + +variable "deployment_user" { + type = string + default = "avmdeploy" + description = "The username for deployment user." +} + variable "enable_telemetry" { type = bool default = true @@ -7,3 +56,15 @@ For more information see . If it is set to false, then no telemetry will be collected. DESCRIPTION } + +variable "rp_service_principal_object_id" { + type = string + default = "" + description = "The object ID of the HCI resource provider service principal." +} + +variable "subnet_mask" { + type = string + default = "255.255.255.0" + description = "The subnet mask for the network." +} diff --git a/keyvault.tf b/keyvault.tf new file mode 100644 index 0000000..f6db051 --- /dev/null +++ b/keyvault.tf @@ -0,0 +1,57 @@ +data "azurerm_client_config" "current" {} + +resource "azurerm_key_vault" "deployment_keyvault" { + location = data.azurerm_resource_group.rg.location + name = var.random_suffix ? "${var.keyvault_name}-${random_integer.random_suffix.result}" : var.keyvault_name + resource_group_name = var.resource_group_name + sku_name = "standard" + tenant_id = data.azurerm_client_config.current.tenant_id + enable_rbac_authorization = true + enabled_for_deployment = true + enabled_for_disk_encryption = true + enabled_for_template_deployment = true + public_network_access_enabled = true + # arm template has enableSoftDelete": false, but terraform can't disable it after version 2.42. + soft_delete_retention_days = 30 + tags = var.tags +} + +resource "azurerm_key_vault_secret" "azure_stack_lcm_user_credential" { + key_vault_id = azurerm_key_vault.deployment_keyvault.id + name = "AzureStackLCMUserCredential" + value = base64encode("${var.deployment_user}:${var.deployment_user_password}") + content_type = "Secret" + tags = var.tags + + depends_on = [azurerm_key_vault.deployment_keyvault] +} + +resource "azurerm_key_vault_secret" "local_admin_credential" { + key_vault_id = azurerm_key_vault.deployment_keyvault.id + name = "LocalAdminCredential" + value = base64encode("${var.local_admin_user}:${var.local_admin_password}") + content_type = "Secret" + tags = var.tags + + depends_on = [azurerm_key_vault.deployment_keyvault] +} + +resource "azurerm_key_vault_secret" "default_arb_application" { + key_vault_id = azurerm_key_vault.deployment_keyvault.id + name = "DefaultARBApplication" + value = base64encode("${var.service_principal_id}:${var.service_principal_secret}") + content_type = "Secret" + tags = var.tags + + depends_on = [azurerm_key_vault.deployment_keyvault] +} + +resource "azurerm_key_vault_secret" "witness_storage_key" { + key_vault_id = azurerm_key_vault.deployment_keyvault.id + name = "WitnessStorageKey" + value = base64encode(azurerm_storage_account.witness.primary_access_key) + content_type = "Secret" + tags = var.tags + + depends_on = [azurerm_key_vault.deployment_keyvault] +} diff --git a/locals.tf b/locals.tf index 73fc331..86dbdaa 100644 --- a/locals.tf +++ b/locals.tf @@ -1,34 +1,93 @@ -# TODO: insert locals here. locals { - managed_identities = { - system_assigned_user_assigned = (var.managed_identities.system_assigned || length(var.managed_identities.user_assigned_resource_ids) > 0) ? { - this = { - type = var.managed_identities.system_assigned && length(var.managed_identities.user_assigned_resource_ids) > 0 ? "SystemAssigned, UserAssigned" : length(var.managed_identities.user_assigned_resource_ids) > 0 ? "UserAssigned" : "SystemAssigned" - user_assigned_resource_ids = var.managed_identities.user_assigned_resource_ids - } - } : {} - system_assigned = var.managed_identities.system_assigned ? { - this = { - type = "SystemAssigned" - } - } : {} - user_assigned = length(var.managed_identities.user_assigned_resource_ids) > 0 ? { - this = { - type = "UserAssigned" - user_assigned_resource_ids = var.managed_identities.user_assigned_resource_ids - } - } : {} + adapter_properties = { + jumboPacket = "" + networkDirect = "Disabled" + networkDirectTechnology = "" + } + combined_adapters = setintersection(toset(var.management_adapters), toset(local.storage_adapters)) + converged = (length(local.combined_adapters) == length(var.management_adapters)) && (length(local.combined_adapters) == length(local.storage_adapters)) + converged_intents = [{ + name = "ManagementComputeStorage", + trafficType = [ + "Management", + "Compute", + "Storage" + ], + adapter = flatten(var.management_adapters), + overrideVirtualSwitchConfiguration = false, + virtualSwitchConfigurationOverrides = { + enableIov = "", + loadBalancingAlgorithm = "" + }, + overrideQosPolicy = false, + qosPolicyOverrides = { + priorityValue8021Action_SMB = "", + priorityValue8021Action_Cluster = "", + bandwidthPercentage_SMB = "" + }, + overrideAdapterProperty = true, + adapterPropertyOverrides = var.rdma_enabled ? local.rdma_adapter_properties : local.adapter_properties + }] + decoded_user_storages = jsondecode(data.azapi_resource_list.user_storages.output).value + owned_user_storages = [for storage in local.decoded_user_storages : storage if lower(storage.extendedLocation.name) == lower(data.azapi_resource.customlocation.id)] + rdma_adapter_properties = { + jumboPacket = "9014" + networkDirect = "Enabled" + networkDirectTechnology = "RoCEv2" } - # Private endpoint application security group associations. - # We merge the nested maps from private endpoints and application security group associations into a single map. - private_endpoint_application_security_group_associations = { for assoc in flatten([ - for pe_k, pe_v in var.private_endpoints : [ - for asg_k, asg_v in pe_v.application_security_group_associations : { - asg_key = asg_k - pe_key = pe_k - asg_resource_id = asg_v - } - ] - ]) : "${assoc.pe_key}-${assoc.asg_key}" => assoc } role_definition_resource_substring = "/providers/Microsoft.Authorization/roleDefinitions" + rp_roles = { + ACMRM = "Azure Connected Machine Resource Manager", + } + seperate_intents = [{ + name = "ManagementCompute", + trafficType = [ + "Management", + "Compute" + ], + adapter = flatten(var.management_adapters) + overrideVirtualSwitchConfiguration = false, + overrideQosPolicy = false, + overrideAdapterProperty = true, + virtualSwitchConfigurationOverrides = { + enableIov = "", + loadBalancingAlgorithm = "" + }, + qosPolicyOverrides = { + priorityValue8021Action_Cluster = "", + priorityValue8021Action_SMB = "", + bandwidthPercentage_SMB = "" + }, + adapterPropertyOverrides = { + jumboPacket = "", + networkDirect = "Disabled", + networkDirectTechnology = "" + } + }, + { + name = "Storage", + trafficType = [ + "Storage" + ], + adapter = local.storage_adapters, + overrideVirtualSwitchConfiguration = false, + overrideQosPolicy = false, + overrideAdapterProperty = true, + virtualSwitchConfigurationOverrides = { + enableIov = "", + loadBalancingAlgorithm = "" + }, + qosPolicyOverrides = { + priorityValue8021Action_Cluster = "", + priorityValue8021Action_SMB = "", + bandwidthPercentage_SMB = "" + }, + adapterPropertyOverrides = var.rdma_enabled ? (var.storage_connectivity_switchless ? local.switchless_adapter_properties : local.rdma_adapter_properties) : local.adapter_properties + }] + storage_adapters = flatten([for storageNetwork in var.storage_networks : storageNetwork.networkAdapterName]) + switchless_adapter_properties = { + jumboPacket = "9014" + networkDirect = "Enabled" + networkDirectTechnology = "iWARP" + } } diff --git a/main.privateendpoint.tf b/main.privateendpoint.tf deleted file mode 100644 index 53e8b71..0000000 --- a/main.privateendpoint.tf +++ /dev/null @@ -1,78 +0,0 @@ -# TODO remove this code & var.private_endpoints if private link is not support. Note it must be included in this module if it is supported. -resource "azurerm_private_endpoint" "this_managed_dns_zone_groups" { - for_each = var.private_endpoints - - location = each.value.location != null ? each.value.location : var.location - name = each.value.name != null ? each.value.name : "pe-${var.name}" - resource_group_name = each.value.resource_group_name != null ? each.value.resource_group_name : var.resource_group_name - subnet_id = each.value.subnet_resource_id - custom_network_interface_name = each.value.network_interface_name - tags = each.value.tags - - private_service_connection { - is_manual_connection = false - name = each.value.private_service_connection_name != null ? each.value.private_service_connection_name : "pse-${var.name}" - private_connection_resource_id = azurerm_resource_group.TODO.id # TODO: Replace this dummy resource azurerm_resource_group.TODO with your module resource - subresource_names = ["TODO subresource name, see https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview#private-link-resource"] - } - dynamic "ip_configuration" { - for_each = each.value.ip_configurations - - content { - name = ip_configuration.value.name - private_ip_address = ip_configuration.value.private_ip_address - member_name = "TODO subresource name" - subresource_name = "TODO subresource name" - } - } - dynamic "private_dns_zone_group" { - for_each = length(each.value.private_dns_zone_resource_ids) > 0 ? ["this"] : [] - - content { - name = each.value.private_dns_zone_group_name - private_dns_zone_ids = each.value.private_dns_zone_resource_ids - } - } -} - -# The PE resource when we are managing **not** the private_dns_zone_group block -# An example use case is customers using Azure Policy to create private DNS zones -# e.g. -resource "azurerm_private_endpoint" "this_unmanaged_dns_zone_groups" { - for_each = { for k, v in var.private_endpoints : k => v if !var.private_endpoints_manage_dns_zone_group } - - location = each.value.location != null ? each.value.location : var.location - name = each.value.name != null ? each.value.name : "pe-${var.name}" - resource_group_name = each.value.resource_group_name != null ? each.value.resource_group_name : var.resource_group_name - subnet_id = each.value.subnet_resource_id - custom_network_interface_name = each.value.network_interface_name - tags = each.value.tags - - private_service_connection { - is_manual_connection = false - name = each.value.private_service_connection_name != null ? each.value.private_service_connection_name : "pse-${var.name}" - private_connection_resource_id = azurerm_resource_group.TODO.id # TODO: Replace this dummy resource azurerm_resource_group.TODO with your module resource - subresource_names = ["TODO subresource name, see https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview#private-link-resource"] - } - dynamic "ip_configuration" { - for_each = each.value.ip_configurations - - content { - name = ip_configuration.value.name - private_ip_address = ip_configuration.value.private_ip_address - member_name = "TODO subresource name" - subresource_name = "TODO subresource name" - } - } - - lifecycle { - ignore_changes = [private_dns_zone_group] - } -} - -resource "azurerm_private_endpoint_application_security_group_association" "this" { - for_each = local.private_endpoint_application_security_group_associations - - application_security_group_id = each.value.asg_resource_id - private_endpoint_id = var.private_endpoints_manage_dns_zone_group ? azurerm_private_endpoint.this_managed_dns_zone_groups[each.value.pe_key].id : azurerm_private_endpoint.this_unmanaged_dns_zone_groups[each.value.pe_key].id -} diff --git a/main.telemetry.tf b/main.telemetry.tf index 0419348..25144c3 100644 --- a/main.telemetry.tf +++ b/main.telemetry.tf @@ -3,7 +3,8 @@ data "azurerm_client_config" "telemetry" { } data "modtm_module_source" "telemetry" { - count = var.enable_telemetry ? 1 : 0 + count = var.enable_telemetry ? 1 : 0 + module_path = path.module } diff --git a/main.tf b/main.tf index bc4625c..18962b7 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,67 @@ # TODO: Replace this dummy resource azurerm_resource_group.TODO with your module resource -resource "azurerm_resource_group" "TODO" { - location = var.location - name = var.name # calling code must supply the name - tags = var.tags +data "azurerm_resource_group" "rg" { + name = var.resource_group_name +} + +data "azapi_resource" "arcbridge" { + type = "Microsoft.ResourceConnector/appliances@2022-10-27" + name = "${var.name}-arcbridge" + parent_id = data.azurerm_resource_group.rg.id + + depends_on = [azapi_update_resource.deploymentsetting] +} + +data "azapi_resource" "customlocation" { + type = "Microsoft.ExtendedLocation/customLocations@2021-08-15" + name = var.custom_location_name + parent_id = data.azurerm_resource_group.rg.id + + depends_on = [azapi_update_resource.deploymentsetting] +} + +data "azapi_resource_list" "user_storages" { + parent_id = data.azurerm_resource_group.rg.id + 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@2023-08-01" + name = "default" + parent_id = azapi_resource.cluster.id + + depends_on = [azapi_update_resource.deploymentsetting] +} + +resource "azapi_resource" "cluster" { + type = "Microsoft.AzureStackHCI/clusters@2023-08-01-preview" + body = { + properties = {} + } + location = var.location + name = var.name + parent_id = data.azurerm_resource_group.rg.id + + identity { + type = "SystemAssigned" + } + + depends_on = [azurerm_role_assignment.service_principal_role_assign] + + lifecycle { + ignore_changes = [ + body.properties, + identity[0] + ] + } +} + +# Generate random integer suffix for storage account and key vault +resource "random_integer" "random_suffix" { + max = 99 + min = 10 } # required AVM resources interfaces @@ -11,7 +70,7 @@ resource "azurerm_management_lock" "this" { lock_level = var.lock.kind name = coalesce(var.lock.name, "lock-${var.lock.kind}") - scope = azurerm_MY_RESOURCE.this.id # TODO: Replace with your azurerm resource name + scope = azapi_resource.cluster.id # TODO: Replace with your azurerm resource name notes = var.lock.kind == "CanNotDelete" ? "Cannot delete the resource or its child resources." : "Cannot delete or modify the resource or its child resources." } @@ -19,7 +78,7 @@ resource "azurerm_role_assignment" "this" { for_each = var.role_assignments principal_id = each.value.principal_id - scope = azurerm_resource_group.TODO.id # TODO: Replace this dummy resource azurerm_resource_group.TODO with your module resource + scope = azapi_resource.cluster.id # TODO: Replace this dummy resource azurerm_resource_group.TODO with your module resource condition = each.value.condition condition_version = each.value.condition_version delegated_managed_identity_resource_id = each.value.delegated_managed_identity_resource_id diff --git a/modules/.terraform-docs.yml b/modules/.terraform-docs.yml index 0587077..e844eb2 100644 --- a/modules/.terraform-docs.yml +++ b/modules/.terraform-docs.yml @@ -4,7 +4,7 @@ formatter: "markdown document" # this is required -version: "~> 0.17.0" +version: "~> 0.18.0" header-from: "_header.md" footer-from: "_footer.md" diff --git a/outputs.tf b/outputs.tf index 5e93e10..c538bbe 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,13 +1,41 @@ -output "private_endpoints" { - description = < server.ipv4Address + } + + name = each.key + resource_group_name = var.resource_group_name +} + +resource "azapi_resource" "validatedeploymentsetting" { + count = local.converged ? 1 : 0 + + type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2023-08-01-preview" + body = { + properties = { + arcNodeResourceIds = flatten([for server in data.azurerm_arc_machine.arcservers : server.id]) + deploymentMode = var.is_exported ? "Deploy" : "Validate" + deploymentConfiguration = { + version = "10.0.0.0" + scaleUnits = [ + { + deploymentData = { + securitySettings = { + hvciProtection = true + drtmProtection = true + driftControlEnforced = true + credentialGuardEnforced = true + smbSigningEnforced = true + smbClusterEncryption = false + sideChannelMitigationEnforced = true + bitlockerBootVolume = true + bitlockerDataVolumes = true + wdacEnforced = true + } + observability = { + streamingDataClient = true + euLocation = false + episodicDataUpload = true + } + cluster = { + name = azapi_resource.cluster.name + witnessType = "Cloud" + witnessPath = "Cloud" + cloudAccountName = azurerm_storage_account.witness.name + azureServiceEndpoint = "core.windows.net" + } + storage = { + configurationMode = "Express" + } + namingPrefix = var.site_id + domainFqdn = var.domain_fqdn + infrastructureNetwork = [{ + useDhcp = false + subnetMask = var.subnet_mask + gateway = var.default_gateway + ipPools = [ + { + startingAddress = var.starting_address + endingEddress = var.ending_address + } + ] + dnsServers = flatten(var.dns_servers) + }] + physicalNodes = flatten(var.servers) + hostNetwork = { + enableStorageAutoIp = true + intents = local.converged_intents + storageNetworks = flatten(var.storage_networks) + storageConnectivitySwitchless = false + } + adouPath = var.adou_path + secretsLocation = azurerm_key_vault.deployment_keyvault.vault_uri + optionalServices = { + customLocation = var.custom_location_name + } + + } + } + ] + } + } + } + name = "default" + parent_id = azapi_resource.cluster.id + + depends_on = [ + azurerm_key_vault_secret.default_arb_application, + azurerm_key_vault_secret.azure_stack_lcm_user_credential, + azurerm_key_vault_secret.local_admin_credential, + azurerm_key_vault_secret.witness_storage_key, + azapi_resource.cluster, + azurerm_role_assignment.service_principal_role_assign, + ] + + lifecycle { + ignore_changes = [ + body.properties.deploymentMode + ] + } +} + +resource "azapi_resource" "validatedeploymentsetting_seperate" { + count = local.converged ? 0 : 1 + + type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2023-08-01-preview" + body = { + properties = { + arcNodeResourceIds = flatten([for server in data.azurerm_arc_machine.arcservers : server.id]) + deploymentMode = "Validate" # Deploy + deploymentConfiguration = { + version = "10.0.0.0" + scaleUnits = [ + { + deploymentData = { + securitySettings = { + hvciProtection = true + drtmProtection = true + driftControlEnforced = true + credentialGuardEnforced = true + smbSigningEnforced = true + smbClusterEncryption = false + sideChannelMitigationEnforced = true + bitlockerBootVolume = true + bitlockerDataVolumes = true + wdacEnforced = true + } + observability = { + streamingDataClient = true + euLocation = false + episodicDataUpload = true + } + cluster = { + name = azapi_resource.cluster.name + witnessType = "Cloud" + witnessPath = "Cloud" + cloudAccountName = azurerm_storage_account.witness.name + azureServiceEndpoint = "core.windows.net" + } + storage = { + configurationMode = "Express" + } + namingPrefix = var.site_id + domainFqdn = var.domain_fqdn + infrastructureNetwork = [{ + useDhcp = false + subnetMask = var.subnet_mask + gateway = var.default_gateway + ipPools = [ + { + startingAddress = var.starting_address + endingAddress = var.ending_address + } + ] + dnsServers = flatten(var.dns_servers) + }] + physicalNodes = flatten(var.servers) + hostNetwork = { + enableStorageAutoIp = true + intents = local.seperate_intents + storageNetworks = flatten(var.storage_networks) + storageConnectivitySwitchless = false + } + adouPath = var.adou_path + secretsLocation = azurerm_key_vault.deployment_keyvault.vault_uri + optionalServices = { + customLocation = var.custom_location_name + } + } + } + ] + } + } + } + name = "default" + parent_id = azapi_resource.cluster.id + + depends_on = [ + azurerm_key_vault_secret.default_arb_application, + azurerm_key_vault_secret.azure_stack_lcm_user_credential, + azurerm_key_vault_secret.local_admin_credential, + azurerm_key_vault_secret.witness_storage_key, + azapi_resource.cluster + ] + + # ignore the deployment mode change after the first deployment + lifecycle { + ignore_changes = [ + body.properties.deploymentMode + ] + } +} diff --git a/variables.tf b/variables.tf index 9182621..f4f3b3d 100644 --- a/variables.tf +++ b/variables.tf @@ -1,95 +1,147 @@ +variable "adou_path" { + type = string + description = "The Active Directory OU path." +} + +variable "custom_location_name" { + type = string + description = "The name of the custom location." +} + +variable "default_gateway" { + type = string + description = "The default gateway for the network." +} + +variable "deployment_user" { + type = string + description = "The username for the domain administrator account." +} + +variable "deployment_user_password" { + type = string + description = "The password for the domain administrator account." + sensitive = true +} + +variable "dns_servers" { + type = list(string) + description = "A list of DNS server IP addresses." + nullable = false +} + +# deploymentSettings related variables +variable "domain_fqdn" { + type = string + description = "The domain FQDN." +} + +variable "ending_address" { + type = string + description = "The ending IP address of the IP address range." +} + +variable "keyvault_name" { + type = string + description = "The name of the key vault." +} + +variable "local_admin_password" { + type = string + description = "The password for the local administrator account." + sensitive = true +} + +variable "local_admin_user" { + type = string + description = "The username for the local administrator account." +} + variable "location" { type = string description = "Azure region where the resource should be deployed." nullable = false } +variable "management_adapters" { + type = list(string) + description = "A list of management adapters." + nullable = false +} + variable "name" { type = string - description = "The name of the this resource." + description = "The name of the HCI cluster. Must be the same as the name when preparing AD." validation { - condition = can(regex("TODO", var.name)) - error_message = "The name must be TODO." # TODO remove the example below once complete: - #condition = can(regex("^[a-z0-9]{5,50}$", var.name)) - #error_message = "The name must be between 5 and 50 characters long and can only contain lowercase letters and numbers." + condition = length(var.name) < 16 && length(var.name) > 0 + error_message = "value of name should be less than 16 characters and greater than 0 characters" } } +variable "rdma_enabled" { + type = bool + description = "Indicates whether RDMA is enabled." +} + # This is required for most resource modules variable "resource_group_name" { type = string description = "The resource group where the resources will be deployed." } -# required AVM interfaces -# remove only if not supported by the resource -# tflint-ignore: terraform_unused_declarations -variable "customer_managed_key" { - type = object({ - key_vault_resource_id = string - key_name = string - key_version = optional(string, null) - user_assigned_identity = optional(object({ - resource_id = string - }), null) - }) - default = null - description = <