From df07217fb4f668457c6db4428e9362ea5c9b9780 Mon Sep 17 00:00:00 2001 From: twerthi Date: Mon, 31 Jul 2023 13:27:32 -0700 Subject: [PATCH 1/2] Adding user managed identity --- .../shared-workers-terraform/azure/azure.tf | 25 +++++++++++++------ .../configure-tentacle.ps1 | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/octopus-samples-instances/shared-workers-terraform/azure/azure.tf b/octopus-samples-instances/shared-workers-terraform/azure/azure.tf index af3fee1..6138aff 100644 --- a/octopus-samples-instances/shared-workers-terraform/azure/azure.tf +++ b/octopus-samples-instances/shared-workers-terraform/azure/azure.tf @@ -29,6 +29,16 @@ resource "azurerm_subnet" "octopus-samples-workers-subnet" { ] } +// Define user managed identity +resource "azurerm_user_assigned_identity" "database-admin" { + location = var.octopus_azure_location + resource_group_name = var.octopus_azure_resourcegroup_name + + name = "samples-database-admin" + + depends_on = [ azurerm_resource_group.octopus-samples-azure-workers ] +} + // Define azure scale set resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" { name = var.octopus_azure_scaleset_name @@ -42,12 +52,14 @@ resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" { user_data = "${base64encode(file("../configure-tentacle.sh"))}" identity { - type = "SystemAssigned" + #type = "SystemAssigned" + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.database-admin.id] } source_image_reference { publisher = "Canonical" - offer = "UbuntuServer" + offer = "0001-com-ubuntu-server-jammy" sku = var.octopus_azure_vm_sku version = "latest" } @@ -68,6 +80,8 @@ resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" { } } tags = var.tags + + depends_on = [ azurerm_user_assigned_identity.database-admin ] } # Create Windows worker @@ -82,12 +96,7 @@ resource "azurerm_network_interface" "windows-worker-nic" { } } -resource "azurerm_user_assigned_identity" "database-admin" { - location = var.octopus_azure_location - resource_group_name = var.octopus_azure_resourcegroup_name - name = "samples-database-admin" -} resource "azurerm_windows_virtual_machine" "samples-windows-worker" { name = var.octopus_azure_windows_worker_name @@ -122,6 +131,8 @@ resource "azurerm_windows_virtual_machine" "samples-windows-worker" { } tags = var.tags + + depends_on = [ azurerm_user_assigned_identity.database-admin ] } resource "azurerm_virtual_machine_extension" "bootstrap-script" { diff --git a/octopus-samples-instances/shared-workers-terraform/configure-tentacle.ps1 b/octopus-samples-instances/shared-workers-terraform/configure-tentacle.ps1 index b10c65f..7012db8 100644 --- a/octopus-samples-instances/shared-workers-terraform/configure-tentacle.ps1 +++ b/octopus-samples-instances/shared-workers-terraform/configure-tentacle.ps1 @@ -26,7 +26,7 @@ catch } # Install .net 4.8 -choco install dotnetfx +#choco install dotnetfx -y # Use chocolaty to install tentacle choco install octopusdeploy.tentacle -y From e6bf552df9864c36ebeadfdfa5d4c8bd44d5fe94 Mon Sep 17 00:00:00 2001 From: twerthi Date: Mon, 31 Jul 2023 15:49:05 -0700 Subject: [PATCH 2/2] Updating azure version --- .../azure-base-infrastructure-terraform/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/octopus-samples-instances/azure-base-infrastructure-terraform/main.tf b/octopus-samples-instances/azure-base-infrastructure-terraform/main.tf index 1467b57..4aacb6b 100644 --- a/octopus-samples-instances/azure-base-infrastructure-terraform/main.tf +++ b/octopus-samples-instances/azure-base-infrastructure-terraform/main.tf @@ -2,7 +2,8 @@ terraform { required_providers { azurerm = { source = "hashicorp/azurerm" - version = ">= 2.93.1" # example: 0.7.62 + #version = ">= 2.93.1" # example: 0.7.62 + version = ">=3.5.0" } }