-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu_virtual_machine.tf
76 lines (74 loc) · 3.42 KB
/
ubuntu_virtual_machine.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
#resource "azurerm_public_ip" "ubuntu-public_ip" {
# name = "ubuntu_public_ip"
# location = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.location
# resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
# allocation_method = "Dynamic"
#}
#resource "azurerm_network_interface_security_group_association" "ubuntu-association" {
# network_interface_id = azurerm_network_interface.ubuntu_internal_network_interface.id
# network_security_group_id = azurerm_network_security_group.nsg.id
#}
resource "azurerm_network_interface" "ubuntu_internal_network_interface" {
name = "ubuntu_internal_network_interface"
location = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.location
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
ip_configuration {
name = "ubuntu-internal-ipconfig"
#private_ip_address_allocation = "Dynamic"
private_ip_address_allocation = "Static"
private_ip_address = cidrhost(var.internal-Prefix, 5)
subnet_id = azurerm_subnet.internal_subnet.id
#public_ip_address_id = azurerm_public_ip.ubuntu-public_ip.id
}
}
resource "azurerm_network_interface" "ubuntu_dmz_network_interface" {
name = "ubuntu_dmz_network_interface"
location = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.location
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
ip_configuration {
name = "ubuntu-dmz-ipconfig"
private_ip_address_allocation = "Static"
private_ip_address = cidrhost(var.dmz-Prefix, 6)
subnet_id = azurerm_subnet.dmz_subnet.id
}
}
resource "azurerm_linux_virtual_machine" "ubuntu_virtual_machine" {
name = "ubuntu_virtual_machine"
computer_name = "ubuntu"
admin_username = random_pet.admin_username.id
disable_password_authentication = true
allow_extension_operations = false
availability_set_id = azurerm_availability_set.fortinet_availability_set.id
location = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.location
resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
network_interface_ids = [azurerm_network_interface.ubuntu_internal_network_interface.id, azurerm_network_interface.ubuntu_dmz_network_interface.id]
size = "Standard_F2s_v2"
admin_ssh_key {
username = random_pet.admin_username.id
public_key = tls_private_key.ssh_key.public_key_openssh
#public_key = file("~/.ssh/id_rsa.pub")
}
# boot_diagnostics {
# storage_account_uri = azurerm_storage_account.storage-account.primary_blob_endpoint
# }
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts-gen2"
version = "latest"
}
}
#data "azurerm_public_ip" "ubuntu-public_ip" {
# name = azurerm_public_ip.ubuntu-public_ip.name
# resource_group_name = data.azurerm_resource_group.AZURE_RESOURCE_GROUP.name
# depends_on = [
# azurerm_linux_virtual_machine.ubuntu_virtual_machine,
# ]
#}
#output "ubuntu-public_ip_address" {
# value = data.azurerm_public_ip.ubuntu-public_ip.ip_address
#}