This repository has been archived by the owner on May 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webserver.tf
executable file
·57 lines (50 loc) · 2.21 KB
/
webserver.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
// Remember to also add monitor diagnostic alerts to a log analytics workspace if applicable
resource "azurerm_resource_group" "web" {
count = var.web ? 1 : 0
name = "${var.prefix}-${var.rg_name}"
location = var.location
}
resource "azurerm_network_interface" "web" {
count = var.web ? 1 : 0
name = "${var.prefix}-${var.web_instance_config.vm_name}-nic-int-web"
location = var.location
resource_group_name = azurerm_resource_group.web[count.index].name
ip_configuration {
name = "internal"
subnet_id = var.subnet_id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.web[count.index].id
}
}
// remove this resource to have only private IP
resource "azurerm_public_ip" "web" {
count = var.web ? 1 : 0
name = "${var.prefix}-${var.web_instance_config.vm_name}-nic-ext-web"
resource_group_name = azurerm_resource_group.web[count.index].name
location = var.location
allocation_method = "Dynamic"
}
resource "azurerm_linux_virtual_machine" "web" {
count = var.web ? 1 : 0
name = "${var.prefix}-${var.web_instance_config.vm_name}"
resource_group_name = azurerm_resource_group.web[count.index].name
location = var.location
size = var.web_instance_config.machine_size
admin_username = var.web_instance_config.admin_username
admin_password = var.web_instance_config.admin_password
disable_password_authentication = var.disable_password_authentication
network_interface_ids = [
azurerm_network_interface.web[count.index].id
]
os_disk {
caching = "ReadWrite"
storage_account_type = var.web_instance_config.os_disk_storage_account_type
}
// source_image_id can replace this if business packer base images are to be used
source_image_reference {
publisher = var.web_instance_config.os_publisher
offer = var.web_instance_config.os_offer
sku = var.web_instance_config.os_sku
version = var.web_instance_config.os_version
}
}