Skip to content

Instantly share code, notes, and snippets.

@gdhagger
Created October 28, 2016 19:01
Show Gist options
  • Save gdhagger/04807210ce3f3364eb044af0df1521e9 to your computer and use it in GitHub Desktop.
Save gdhagger/04807210ce3f3364eb044af0df1521e9 to your computer and use it in GitHub Desktop.
resource "azurerm_virtual_machine" "k8s-node" {
count = "${var.node_vm_count}"
name = "k8s-node-${count.index}"
location = "${var.location}"
resource_group_name = "${var.resource_group}"
network_interface_ids = ["${element(azurerm_network_interface.k8s-node.*.id, count.index)}"]
availability_set_id = "${azurerm_availability_set.k8s-node.id}"
vm_size = "${var.node_vm_size}"
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04.0-LTS"
version = "latest"
}
storage_os_disk {
name = "k8s-nodedisk1"
vhd_uri = "${element(azurerm_storage_account.k8s-node.*.primary_blob_endpoint, count.index)}${element(azurerm_storage_container.k8s-node.*.name, count.index)}/k8s-node-${count.index}disk1.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}
os_profile {
computer_name = "k8s-node-${count.index}"
admin_username = "REDACTED"
admin_password = "REDACTED"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "REDACTED"
key_data = "REDACTED"
}
}
tags {
environment = "${var.environment}"
version = "${var.version}"
}
lifecycle {
ignore_changes = ["storage_data_disk"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment