-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
90 lines (82 loc) · 3.01 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
82
83
84
85
86
87
88
89
90
resource "random_pet" "main" {
length = 2
separator = ""
}
resource "azurerm_resource_group" "main" {
name = var.resource_group_name
location = var.location
}
resource "azurerm_virtual_network" "main" {
name = random_pet.main.id
location = var.location
resource_group_name = var.resource_group_name
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "main" {
name = random_pet.main.id
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.0.0/24"]
}
resource "azurerm_public_ip" "main" {
name = random_pet.main.id
resource_group_name = var.resource_group_name
location = var.location
allocation_method = "Static"
sku = "Standard"
}
resource "azurerm_network_interface" "main" {
name = random_pet.main.id
location = var.location
resource_group_name = var.resource_group_name
ip_configuration {
name = random_pet.main.id
subnet_id = azurerm_subnet.main.id
private_ip_address_allocation = "Static"
private_ip_address = "10.0.0.5"
public_ip_address_id = azurerm_public_ip.main.id
}
}
resource "azurerm_network_security_group" "main" {
name = random_pet.main.id
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
security_rule {
name = "SSH"
priority = 1001
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefix = "*"
destination_address_prefix = "*"
}
}
resource "azurerm_network_interface_security_group_association" "main" {
network_interface_id = azurerm_network_interface.main.id
network_security_group_id = azurerm_network_security_group.main.id
}
resource "azurerm_linux_virtual_machine" "main" {
name = var.vm_name
resource_group_name = var.resource_group_name
location = var.location
size = var.vm_size
network_interface_ids = [
azurerm_network_interface.main.id
]
disable_password_authentication = false
admin_username = var.local_admin_username
admin_password = var.local_admin_password
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
name = var.vm_name
}
source_image_reference {
publisher = var.vm_image_publisher
offer = var.vm_image_offer
sku = var.vm_image_sku
version = var.vm_image_version
}
}