This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
9-create-vmss.tf
84 lines (69 loc) · 2.27 KB
/
9-create-vmss.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
variable "vmssskusize" {
type = string
default = "Standard_B1s"
}
variable "vmssvmtocreate" {
type = number
default = 2
}
variable "automaticupgrade" {
type = bool
default = false
}
variable "vmssupgradepolicy" {
type = string
default = "Manual"
}
variable "vmssstoragesku" {
type = string
default = "Standard_LRS"
}
variable "vmssaceleratednetworking" {
type = bool
default = false
}
resource "azurerm_virtual_machine_scale_set" "main" {
name = "${var.prefix}VMSS"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
# automatic rolling upgrade
automatic_os_upgrade = var.automaticupgrade
upgrade_policy_mode = var.vmssupgradepolicy
# required when using rolling upgrade policy
health_probe_id = "${azurerm_lb_probe.http.id}"
sku {
name = var.vmssskusize
capacity = var.vmssvmtocreate
}
storage_profile_image_reference {
id = "${azurerm_image.main.id}"
}
storage_profile_os_disk {
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = var.vmssstoragesku
}
os_profile {
computer_name_prefix = "${var.prefix}VMSS"
admin_username = var.loginusername
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/${var.loginusername}/.ssh/authorized_keys"
key_data = var.authenticationkey
}
}
network_profile {
name = "${var.prefix}VMSSNetworkProfile"
primary = true
accelerated_networking = var.vmssaceleratednetworking
ip_configuration {
name = "${var.prefix}VMSS-ipconfig"
primary = true
subnet_id = "${azurerm_subnet.compute.id}"
load_balancer_backend_address_pool_ids = ["${azurerm_lb_backend_address_pool.main.id}"]
load_balancer_inbound_nat_rules_ids = ["${azurerm_lb_nat_pool.main.id}"]
}
}
}