-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.tf
127 lines (93 loc) · 3.72 KB
/
demo.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
locals {
resource_group_name = var.resource_group_name
location = var.location
admin_username = var.admin_username
admin_password = var.admin_password
}
resource "azurerm_resource_group" "example" {
name = local.resource_group_name
location = local.location
}
resource "azurerm_dedicated_host_group" "example" {
count = var.use_dedicated_host ? 1 : 0
name = "my-host-group"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
platform_fault_domain_count = 2
}
resource "azurerm_dedicated_host" "example" {
count = var.use_dedicated_host ? 1 : 0
name = "example-host"
location = azurerm_resource_group.example.location
dedicated_host_group_id = azurerm_dedicated_host_group.example.0.id
sku_name = "ESv3-Type1"
platform_fault_domain = 1
}
module "virtual_network" {
source = "github.com/hyundonk/terraform-azurerm-caf-virtual-network"
prefix = "demo"
virtual_network_rg = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
networking_object = var.networking_object
tags = {}
}
module "pip" {
source = "git://github.com/hyundonk/aztf-module-pip.git"
prefix = "demo"
services = var.pip
location = azurerm_resource_group.example.location
rg = azurerm_resource_group.example.name
tags = {}
}
resource "azurerm_network_interface" "example" {
name = "demo-nic"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
ip_configuration {
name = "internal"
subnet_id = module.virtual_network.subnet_ids_map["frontend"]
private_ip_address_allocation = "Dynamic"
public_ip_address_id = module.pip.public_ip.0.id
}
}
resource "azurerm_linux_virtual_machine" "vm" {
name = var.vm.name
resource_group_name = local.resource_group_name
location = local.location
size = var.vm.vm_size
admin_username = local.admin_username
admin_password = local.admin_password
disable_password_authentication = false
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
}
source_image_reference {
publisher = var.vm.vm_publisher
offer = var.vm.vm_offer
sku = var.vm.vm_sku
version = var.vm.vm_version
}
network_interface_ids = [azurerm_network_interface.example.id]
dedicated_host_id = var.use_dedicated_host ? azurerm_dedicated_host.example.0.id : null
tags = {}
}
resource "azurerm_managed_disk" "example" {
count = var.num_disk
name = "datadisk${count.index+1}"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
storage_account_type = "Premium_LRS"
create_option = "Empty"
disk_size_gb = "1024"
}
resource "azurerm_virtual_machine_data_disk_attachment" "lun0" {
count = var.num_disk
managed_disk_id = element(azurerm_managed_disk.example.*.id, count.index)
virtual_machine_id = azurerm_linux_virtual_machine.vm.id
lun = count.index
caching = "None"
}
output "pip" {
value = module.pip.public_ip
}