Skip to content

Instantly share code, notes, and snippets.

@heoelri
Last active May 29, 2021 17:58
Show Gist options
  • Save heoelri/11b55c94646b01c1f7666122f5df90bd to your computer and use it in GitHub Desktop.
Save heoelri/11b55c94646b01c1f7666122f5df90bd to your computer and use it in GitHub Desktop.
Azure VMSS deployed via Terraform with cloud init
resource "azurerm_linux_virtual_machine_scale_set" "deployment" {
name = "buildagent-vmss"
resource_group_name = azurerm_resource_group.deployment.name
location = azurerm_resource_group.deployment.location
sku = "Standard_F8s_v2"
instances = var.numberOfWorkerNodes # number of instances
overprovision = false
single_placement_group = false
admin_username = "adminuser"
admin_password = azurerm_key_vault_secret.vmsecret.value
disable_password_authentication = false
custom_data = base64encode(data.local_file.cloudinit.content)
source_image_reference {
publisher = "canonical"
offer = "0001-com-ubuntu-server-focal"
sku = "20_04-lts"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadOnly"
diff_disk_settings {
option = "Local"
}
}
network_interface {
name = "${local.prefix}-vmss-nic"
primary = true
ip_configuration {
name = "${local.prefix}-vmss-ipconfig"
primary = true
subnet_id = azurerm_subnet.deployment.id
}
}
boot_diagnostics {
storage_account_uri = null
}
}
# Data template Bash bootstrapping file
data "local_file" "cloudinit" {
filename = "${path.module}/cloudinit.conf"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment