diff --git a/infrastructure/Azure/.terraform.lock.hcl b/infrastructure/Azure/.terraform.lock.hcl index 8596c9d..25aef6c 100644 --- a/infrastructure/Azure/.terraform.lock.hcl +++ b/infrastructure/Azure/.terraform.lock.hcl @@ -18,23 +18,6 @@ provider "registry.opentofu.org/hashicorp/azurerm" { ] } -provider "registry.opentofu.org/hashicorp/time" { - version = "0.13.1" - hashes = [ - "h1:3X1jTAlLJV6G9AylC+BgX7WrKFcZYHqA+Z4JwB+v7as=", - "zh:10f32af8b544a039f19abd546e345d056a55cb7bdd69d5bbd7322cbc86883848", - "zh:35dd5beb34a9f73de8d0fed332814c69acae69397c9c065ce63ccd8315442bef", - "zh:56545d1dd5f2e7262e0c0c124264974229ec9cc234d0d7a0e36e14b869590f4a", - "zh:8d7259c3f819fd3470ff933c904b6a549502a8351feb1b5c040a4560decaf7e0", - "zh:a40f26878826b142e26fe193f7e3e14fc97f615cd6af140e88ce5bc25f3fcf50", - "zh:b2e82f25fecff172a9a9e24ea37d37e4fc630ee9245617cb40b10e66a6b979c8", - "zh:d4b699850a40ed07ef83c6b827605d24050b2732646ee017bda278e4ddf01c91", - "zh:e4e6a5e5614b6a54557400aabb748ebd57e947cdbd21ad1c7602c51368a80559", - "zh:eb78fb97bca22931e730487a20a90f5a6221ddfb3138aaf070737ea2b7c9c885", - "zh:faba366a1352ee679bba2a5b09c073c6854721db94b191d49b620b60946a065f", - ] -} - provider "registry.opentofu.org/hashicorp/tls" { version = "4.1.0" hashes = [ diff --git a/infrastructure/Azure/locals.tf b/infrastructure/Azure/locals.tf index ec8d9e0..30ca84a 100644 --- a/infrastructure/Azure/locals.tf +++ b/infrastructure/Azure/locals.tf @@ -1,5 +1,8 @@ # --- Local Values for Naming Convention --- locals { + workgroup_name_lower = lower(var.workgroup_name) + workgroup_name_alnum = replace(local.workgroup_name_lower, "-", "") + # Resource Group: {workgroup name}-rhino-{environment}-rg-{seq#} resource_group_name = "${var.workgroup_name}-rhino-${var.environment}-rg-${var.sequence_number}" @@ -12,10 +15,17 @@ locals { # Virtual Machine: {workgroup name}-rhino-{environment}-{seq#} vm_name = "${var.workgroup_name}-rhino-${var.environment}-${var.sequence_number}" - # Storage Accounts: {workgroup name}rhino{type}{seq#} (lowercase, no hyphens for Azure storage account naming) - storage_account_output_logs_name = "${replace(var.workgroup_name, "-", "")}rhinooutput${var.sequence_number}" - storage_account_source_data_name = "${replace(var.workgroup_name, "-", "")}rhinoinput${var.sequence_number}" - storage_account_logs_name = "${replace(var.workgroup_name, "-", "")}rhinolog${var.sequence_number}" + # Azure storage account names are limited to 24 lowercase alphanumeric characters. + storage_account_prefix_max_length = 24 - length(var.sequence_number) - 3 + storage_account_prefix = substr(local.workgroup_name_alnum, 0, local.storage_account_prefix_max_length) + storage_account_output_logs_name = "${local.storage_account_prefix}out${var.sequence_number}" + storage_account_source_data_name = "${local.storage_account_prefix}in${var.sequence_number}" + storage_account_logs_name = "${local.storage_account_prefix}log${var.sequence_number}" + + # Azure Key Vault names are limited to 24 characters and allow dashes. + key_vault_prefix_max_length = 24 - length(var.environment) - 7 + key_vault_prefix = trimsuffix(substr(local.workgroup_name_lower, 0, local.key_vault_prefix_max_length), "-") + key_vault_name = "${local.key_vault_prefix}-rh-${var.environment}-kv" # Standard tags for cost aggregation common_tags = { diff --git a/infrastructure/Azure/main.tf b/infrastructure/Azure/main.tf index 343763f..9f4fb58 100644 --- a/infrastructure/Azure/main.tf +++ b/infrastructure/Azure/main.tf @@ -273,7 +273,7 @@ resource "tls_private_key" "rhino" { # Create Key Vault resource "azurerm_key_vault" "main" { - name = "${var.workgroup_name}-rhino-${var.environment}-kv" + name = local.key_vault_name location = azurerm_resource_group.main.location resource_group_name = azurerm_resource_group.main.name tenant_id = var.tenant_id @@ -384,8 +384,10 @@ resource "azurerm_linux_virtual_machine" "main" { } custom_data = base64encode(format( - "#!/bin/bash\ncurl -fsS --proto '=https' https://activate.rhinohealth.com | sudo RHINO_AGENT_ID='%s' PACKAGE_REGISTRY_USER='%s' PACKAGE_REGISTRY_PASSWORD='%s' SKIP_HW_CHECK=True bash -", + "#!/bin/bash\ncurl -fsS --proto '=https' https://activate.rhinohealth.com | sudo RHINO_AGENT_ID='%s' ROLE_ID='%s' SECRET_ID='%s' PACKAGE_REGISTRY_USER='%s' PACKAGE_REGISTRY_PASSWORD='%s' SKIP_HW_CHECK=True bash -", var.rhino_agent_id, + var.rhino_role_id, + var.rhino_secret_id, var.rhino_package_registry_user, var.rhino_package_registry_password )) diff --git a/infrastructure/Azure/variables.tf b/infrastructure/Azure/variables.tf index aeda460..8fd0ade 100644 --- a/infrastructure/Azure/variables.tf +++ b/infrastructure/Azure/variables.tf @@ -89,6 +89,18 @@ variable "rhino_agent_id" { sensitive = true } +variable "rhino_role_id" { + description = "The role ID for the Rhino Health installation." + type = string + sensitive = true +} + +variable "rhino_secret_id" { + description = "The secret ID for the Rhino Health installation." + type = string + sensitive = true +} + variable "rhino_package_registry_user" { description = "The user for the Rhino Health package registry." type = string