-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
77 lines (67 loc) · 1.94 KB
/
main.tf
File metadata and controls
77 lines (67 loc) · 1.94 KB
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
/* locals {
nicName = "${local.serverName}-NIC"
osDiskName = "${local.serverName}-OSDisk"
ipConfigName = "${local.serverName}-IPConfig"
serverName = "${var.serverNamePrefix}${count.index}"
}
*/
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.65"
}
}
required_version = ">= 0.14.9"
}
provider "azurerm" {
features {
}
}
resource "azurerm_resource_group" "rg" {
name = var.rgName
location = var.rgLocation
}
data "azurerm_subnet" "existingSubnet" {
name = var.deploymentSubnetName
virtual_network_name = var.deploymentVnetName
resource_group_name = var.vnetRGName
}
resource "azurerm_network_interface" "vmNic" {
count = var.numberOfVMs
//name = local.nicName
name = "${var.serverNamePrefix}${count.index +1}-NIC"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
ip_configuration {
//name = local.ipConfigName
name = "${var.serverNamePrefix}${count.index+1}-IPConfig"
subnet_id = "${data.azurerm_subnet.existingSubnet.id}"
private_ip_address_allocation = "dynamic"
}
}
resource "azurerm_windows_virtual_machine" "vm" {
count = var.numberOfVMs
//name = local.serverName
name = "${var.serverNamePrefix}${count.index+1}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vmSize
admin_username = "DenisCooper"
admin_password = "MyPassword@123"
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
//name = local.osDiskName
name = "${var.serverNamePrefix}${count.index+1}-OSDisk"
}
source_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2016-Datacenter"
version = "latest"
}
network_interface_ids = [
azurerm_network_interface.vmNic[count.index].id
]
}