75 lines
1.8 KiB
HCL
75 lines
1.8 KiB
HCL
resource "random_id" "randomMachineId" {
|
|
keepers = {
|
|
# Generate a new ID only when a new resource group is defined
|
|
resource_group = var.resource_group_name
|
|
}
|
|
|
|
byte_length = 2
|
|
}
|
|
|
|
resource "random_password" "password" {
|
|
length = 16
|
|
special = true
|
|
override_special = "_!@"
|
|
upper = true
|
|
lower = true
|
|
min_lower = 2
|
|
min_upper = 2
|
|
min_special = 2
|
|
}
|
|
|
|
resource "random_password" "qlikpassword" {
|
|
length = 16
|
|
special = true
|
|
override_special = "_!@"
|
|
upper = true
|
|
lower = true
|
|
min_lower = 2
|
|
min_upper = 2
|
|
min_special = 2
|
|
}
|
|
|
|
locals {
|
|
virtual_machine_name = "${var.prefix}-${random_id.randomMachineId.hex}"
|
|
admin_username = var.admin_username
|
|
admin_password = random_password.password.result
|
|
}
|
|
|
|
module "qmi-nic" {
|
|
source = "git::https://gitlab.com/qmi/qmi-cloud-tf-modules.git//qmi-nic"
|
|
|
|
prefix = local.virtual_machine_name
|
|
location = var.location
|
|
resource_group_name = var.resource_group_name
|
|
subnet_id = var.vm_subnet_id
|
|
|
|
user_id = var.user_id
|
|
|
|
}
|
|
|
|
resource "azurerm_windows_virtual_machine" "vm" {
|
|
name = local.virtual_machine_name
|
|
resource_group_name = var.resource_group_name
|
|
location = var.location
|
|
size = var.vm_type
|
|
admin_username = local.admin_username
|
|
admin_password = local.admin_password
|
|
network_interface_ids = [ module.qmi-nic.id ]
|
|
|
|
os_disk {
|
|
name = "${local.virtual_machine_name}-osdisk"
|
|
caching = "ReadWrite"
|
|
storage_account_type = var.managed_disk_type
|
|
disk_size_gb = var.disk_size_gb
|
|
}
|
|
|
|
source_image_id = var.image_reference
|
|
|
|
tags = {
|
|
"Deployment" = "QMI PoC"
|
|
"Cost Center" = "3100"
|
|
"QMI_user" = var.user_id
|
|
"Owner" = var.user_id != null? var.user_id : null
|
|
"24x7" = ""
|
|
}
|
|
} |