From f6c9394636ab4ea0062a489a90b093fbe3b22698 Mon Sep 17 00:00:00 2001 From: Jon Calalang Date: Wed, 17 Jan 2024 19:40:33 -0800 Subject: [PATCH] string? --- .../activeDirectoryInstances.tf | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/services/active-directory/terraform/infrastructure/activeDirectoryInstances.tf b/services/active-directory/terraform/infrastructure/activeDirectoryInstances.tf index 500ee72e..bd5d6969 100644 --- a/services/active-directory/terraform/infrastructure/activeDirectoryInstances.tf +++ b/services/active-directory/terraform/infrastructure/activeDirectoryInstances.tf @@ -1,8 +1,12 @@ ## Active Directory Instances Terraform # Random id generator -resource "random_id" "active-directory-random-id" { - byte_length = 16 +resource "random_string" "active-directory-random-string" { + length = 4 + min_lower = 2 + min_numeric = 2 + special = false + upper = false count = sum([var.active-directory-instance-count]) } @@ -37,7 +41,7 @@ resource "azurerm_network_interface_security_group_association" "active-director # Active Directory Instances NICs resource "azurerm_network_interface" "nic-instances" { - name = "nic-${random_id.active-directory-random-id[0].result}-${count.index}" + name = "nic-${random_string.active-directory-random-string[0].result}-${count.index}" location = azurerm_resource_group.active-directory-resource-group.location resource_group_name = azurerm_resource_group.active-directory-resource-group.name count = sum([var.active-directory-instance-count]) @@ -57,7 +61,7 @@ resource "azurerm_network_interface" "nic-instances" { # Active Directory Instances resource "azurerm_windows_virtual_machine" "active-directory-instance" { - name = "win-${random_id.active-directory-random-id[0].result}-${count.index}" + name = "win-${random_string.active-directory-random-string[0].result}-${count.index}" admin_username = var.active-directory-username admin_password = var.active-directory-password location = azurerm_resource_group.active-directory-resource-group.location @@ -75,7 +79,7 @@ resource "azurerm_windows_virtual_machine" "active-directory-instance" { } os_disk { - name = "os-disk-${random_id.active-directory-random-id[0].result}-${count.index}" + name = "os-disk-${random_string.active-directory-random-string[0].result}-${count.index}" caching = "ReadWrite" storage_account_type = "Premium_LRS" } @@ -87,14 +91,9 @@ resource "azurerm_windows_virtual_machine" "active-directory-instance" { } } -# Active Directory Instances bootstrapping file -# data "template_file" "bootstrap-instance-group-azure-instances" { -# template = templatefile("${path.module}/files/bootstrap-instance-group-azure-instances.sh", { nms-hostname = var.nms-hostname }) -# } - ## Availability Set resource "azurerm_availability_set" "active-directory-instance" { - name = "a-set-${random_id.active-directory-random-id[0].result}-${count.index}" + name = "a-set-${random_string.active-directory-random-string[0].result}-${count.index}" location = var.location resource_group_name = azurerm_resource_group.active-directory-resource-group.name