Skip to content

Commit e27d560

Browse files
committed
chore: support using full resource group ID
as that is what we support in meshStack as Platform Tenant ID
1 parent b46243c commit e27d560

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

modules/azure/azure-virtual-machine/buildingblock/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ No modules.
189189
| <a name="input_os_disk_size_gb"></a> [os\_disk\_size\_gb](#input\_os\_disk\_size\_gb) | The size of the OS disk in GB | `number` | `30` | no |
190190
| <a name="input_os_disk_storage_type"></a> [os\_disk\_storage\_type](#input\_os\_disk\_storage\_type) | The storage account type for the OS disk | `string` | `"Standard_LRS"` | no |
191191
| <a name="input_os_type"></a> [os\_type](#input\_os\_type) | The operating system type (Linux or Windows) | `string` | `"Linux"` | no |
192-
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of the resource group. If not provided, a new resource group will be created. | `string` | `null` | no |
192+
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name or full resource ID of the resource group (e.g., '/subscriptions/.../resourceGroups/my-rg'). If not provided, a new resource group will be created. | `string` | `null` | no |
193193
| <a name="input_spot_eviction_policy"></a> [spot\_eviction\_policy](#input\_spot\_eviction\_policy) | Eviction policy for spot instances (Deallocate or Delete) | `string` | `"Deallocate"` | no |
194194
| <a name="input_spot_max_bid_price"></a> [spot\_max\_bid\_price](#input\_spot\_max\_bid\_price) | Maximum price to pay for spot instance per hour. -1 means pay up to on-demand price. Default is -1 for maximum availability | `number` | `-1` | no |
195195
| <a name="input_ssh_public_key"></a> [ssh\_public\_key](#input\_ssh\_public\_key) | SSH public key for Linux VM authentication (required for Linux) | `string` | `null` | no |

modules/azure/azure-virtual-machine/buildingblock/main.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ data "azurerm_subscription" "current" {}
33
data "azurerm_client_config" "current" {}
44

55
locals {
6-
# Use provided resource group name or create a new one
7-
resource_group_name = var.resource_group_name != null ? var.resource_group_name : "${var.vm_name}-rg"
6+
# Determine if input is a resource ID (starts with /) or a name
7+
is_resource_id = var.resource_group_name != null ? startswith(var.resource_group_name, "/") : false
8+
9+
# Extract resource group name from resource ID if applicable
10+
rg_name_from_id = local.is_resource_id ? element(split("/", var.resource_group_name), length(split("/", var.resource_group_name)) - 1) : null
11+
12+
# Use provided resource group name/ID or create a new one
13+
resource_group_name = var.resource_group_name != null ? (local.is_resource_id ? local.rg_name_from_id : var.resource_group_name) : "${var.vm_name}-rg"
14+
815
# Determine if we need to create a resource group
916
create_resource_group = var.resource_group_name == null
1017
}

modules/azure/azure-virtual-machine/buildingblock/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ variable "vm_name" {
55

66
variable "resource_group_name" {
77
type = string
8-
description = "The name of the resource group. If not provided, a new resource group will be created."
8+
description = "The name or full resource ID of the resource group (e.g., '/subscriptions/.../resourceGroups/my-rg'). If not provided, a new resource group will be created."
99
default = null
1010
}
1111

0 commit comments

Comments
 (0)