-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvm-azure.tf
63 lines (51 loc) · 1.83 KB
/
vm-azure.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
resource "azurerm_resource_group" "resource_group" {
name = "vm"
location = var.location
tags = local.common_tags
}
resource "azurerm_public_ip" "public_ip" {
name = "public-ip-terraform"
resource_group_name = azurerm_resource_group.resource_group.name
location = var.location
allocation_method = "Dynamic"
tags = local.common_tags
}
resource "azurerm_network_interface" "network_interface" {
name = "network-interface-terraform"
location = var.location
resource_group_name = azurerm_resource_group.resource_group.name
ip_configuration {
name = "public-ip-terraform"
subnet_id = data.terraform_remote_state.vnet.outputs.subnet_id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.public_ip.id
}
tags = local.common_tags
}
resource "azurerm_network_interface_security_group_association" "nisga" {
network_interface_id = azurerm_network_interface.network_interface.id
network_security_group_id = data.terraform_remote_state.vnet.outputs.security_group_id
}
resource "azurerm_linux_virtual_machine" "vm" {
name = "vm-terraform"
resource_group_name = azurerm_resource_group.resource_group.name
location = var.location
size = "Standard_B1s"
admin_username = "terraform"
network_interface_ids = [azurerm_network_interface.network_interface.id]
admin_ssh_key {
username = "terraform"
public_key = file(var.azure_pub_key)
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "20.04-LTS"
version = "latest"
}
tags = local.common_tags
}