forked from pmnathandev/tfworkshopdemo-azure
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
55 lines (47 loc) · 1.79 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
resource "azurerm_virtual_network" "example" {
name = "example-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.app_dev_rg_test_01.location
resource_group_name = azurerm_resource_group.app_dev_rg_test_01.name
}
resource "azurerm_subnet" "example" {
name = "internal"
resource_group_name = azurerm_resource_group.app_dev_rg_test_01.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azurerm_network_interface" "example" {
count = var.instances
name = "example-nic"
location = azurerm_resource_group.app_dev_rg_test_01.location
resource_group_name = azurerm_resource_group.app_dev_rg_test_01.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.example.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_linux_virtual_machine" "example" {
name = "example-machine-${count.index}"
resource_group_name = azurerm_resource_group.app_dev_rg_test_01.name
location = azurerm_resource_group.app_dev_rg_test_01.location
count = var.instances
size = "Standard_A1"
#size = "Standard_H16m"
admin_username = "adminuser"
network_interface_ids = [element(azurerm_network_interface.example.*.id, count.index)]
admin_ssh_key {
username = "adminuser"
public_key = file("./pubkey/id_rsa.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
}