-
Notifications
You must be signed in to change notification settings - Fork 71
/
main.tf
82 lines (69 loc) · 2.4 KB
/
main.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
resource "azurerm_resource_group" "module" {
name = "${local.module_name}-rg"
location = var.location
tags = {
environment = "dev"
version = "v0.12.0"
}
}
resource "azurerm_network_interface" "module" {
name = "${local.module_name}-nic${count.index}"
location = azurerm_resource_group.module.location
resource_group_name = azurerm_resource_group.module.name
count = var.vm_count
ip_configuration {
name = "ipconfig-${count.index}"
subnet_id = var.subnet_id
private_ip_address_allocation = "dynamic"
}
tags = {
environment = "dev"
}
}
resource "azurerm_virtual_machine" "module" {
name = "${local.module_name}-vm${count.index}"
location = azurerm_resource_group.module.location
resource_group_name = azurerm_resource_group.module.name
network_interface_ids = [azurerm_network_interface.module[count.index].id]
count = var.vm_count
vm_size = var.size
delete_os_disk_on_termination = var.delete_os_disk_on_termination
delete_data_disks_on_termination = var.delete_data_disks_on_termination
storage_image_reference {
publisher = element(split(":", var.os), 0)
offer = element(split(":", var.os), 1)
sku = element(split(":", var.os), 2)
version = element(split(":", var.os), 3)
}
storage_os_disk {
caching = "ReadWrite"
create_option = "FromImage"
name = "${local.module_name}-vm${count.index}-os"
managed_disk_type = var.disk_os_sku
}
storage_data_disk {
create_option = "Empty"
lun = 0
name = "${local.module_name}-vm${count.index}-data0"
managed_disk_type = var.disk_data_sku
disk_size_gb = var.disk_data_size_gb
}
storage_data_disk {
create_option = "Empty"
lun = 1
name = "${local.module_name}-vm${count.index}-data1"
managed_disk_type = var.disk_data_sku
disk_size_gb = var.disk_data_size_gb
}
os_profile {
computer_name = "${local.module_name}vm${count.index}"
admin_username = var.username
admin_password = var.password
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
environment = "dev"
}
}