2022-10-06 05:51:26 -04:00
|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
azurerm = {
|
|
|
|
source = "hashicorp/azurerm"
|
2023-09-26 07:17:17 -04:00
|
|
|
version = "3.74.0"
|
2022-10-06 05:51:26 -04:00
|
|
|
}
|
|
|
|
random = {
|
|
|
|
source = "hashicorp/random"
|
2023-05-16 10:01:47 -04:00
|
|
|
version = "3.5.1"
|
2022-10-06 05:51:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-22 10:53:40 -04:00
|
|
|
locals {
|
|
|
|
tags = merge(
|
|
|
|
var.tags,
|
|
|
|
{ constellation-role = var.role },
|
|
|
|
{ constellation-node-group = var.node_group_name },
|
|
|
|
)
|
|
|
|
group_uid = random_id.uid.hex
|
2023-06-23 06:08:30 -04:00
|
|
|
name = "${var.base_name}-${var.role}-${local.group_uid}"
|
2023-06-22 10:53:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "random_id" "uid" {
|
|
|
|
byte_length = 4
|
|
|
|
}
|
2022-10-06 05:51:26 -04:00
|
|
|
resource "random_password" "password" {
|
2022-11-01 21:08:41 -04:00
|
|
|
length = 16
|
|
|
|
min_lower = 1
|
|
|
|
min_upper = 1
|
|
|
|
min_numeric = 1
|
|
|
|
min_special = 1
|
2022-10-06 05:51:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_linux_virtual_machine_scale_set" "scale_set" {
|
2023-06-22 10:53:40 -04:00
|
|
|
name = local.name
|
2022-10-06 05:51:26 -04:00
|
|
|
resource_group_name = var.resource_group
|
|
|
|
location = var.location
|
|
|
|
sku = var.instance_type
|
2023-06-30 04:53:00 -04:00
|
|
|
instances = var.initial_count
|
2022-10-06 05:51:26 -04:00
|
|
|
admin_username = "adminuser"
|
|
|
|
admin_password = random_password.password.result
|
|
|
|
overprovision = false
|
2022-10-21 04:06:02 -04:00
|
|
|
provision_vm_agent = false
|
2022-10-06 05:51:26 -04:00
|
|
|
vtpm_enabled = true
|
|
|
|
disable_password_authentication = false
|
|
|
|
upgrade_mode = "Manual"
|
2022-10-19 07:10:15 -04:00
|
|
|
secure_boot_enabled = var.secure_boot
|
2022-10-06 05:51:26 -04:00
|
|
|
source_image_id = var.image_id
|
2023-06-22 10:53:40 -04:00
|
|
|
tags = local.tags
|
|
|
|
zones = var.zones
|
2022-10-06 05:51:26 -04:00
|
|
|
identity {
|
|
|
|
type = "UserAssigned"
|
|
|
|
identity_ids = [var.user_assigned_identity]
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_diagnostics {}
|
|
|
|
|
|
|
|
dynamic "os_disk" {
|
|
|
|
for_each = var.confidential_vm ? [1] : [] # if confidential_vm is true
|
|
|
|
content {
|
|
|
|
security_encryption_type = "VMGuestStateOnly"
|
|
|
|
caching = "ReadWrite"
|
|
|
|
storage_account_type = "Premium_LRS"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dynamic "os_disk" {
|
|
|
|
for_each = var.confidential_vm ? [] : [1] # else
|
|
|
|
content {
|
|
|
|
caching = "ReadWrite"
|
|
|
|
storage_account_type = "Premium_LRS"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data_disk {
|
|
|
|
storage_account_type = var.state_disk_type
|
|
|
|
disk_size_gb = var.state_disk_size
|
|
|
|
caching = "ReadWrite"
|
|
|
|
lun = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
network_interface {
|
|
|
|
name = "node-network"
|
|
|
|
primary = true
|
|
|
|
network_security_group_id = var.network_security_group_id
|
|
|
|
|
|
|
|
ip_configuration {
|
|
|
|
name = "node-network"
|
|
|
|
primary = true
|
|
|
|
subnet_id = var.subnet_id
|
|
|
|
load_balancer_backend_address_pool_ids = var.backend_address_pool_ids
|
|
|
|
}
|
|
|
|
}
|
2022-11-07 05:04:10 -05:00
|
|
|
|
|
|
|
lifecycle {
|
|
|
|
ignore_changes = [
|
2023-06-22 10:53:40 -04:00
|
|
|
name, # required. Allow legacy scale sets to keep their old names
|
2022-11-07 05:04:10 -05:00
|
|
|
instances, # required. autoscaling modifies the instance count externally
|
|
|
|
source_image_id, # required. update procedure modifies the image id externally
|
|
|
|
]
|
|
|
|
}
|
2022-10-06 05:51:26 -04:00
|
|
|
}
|