-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
69 lines (57 loc) · 1.89 KB
/
Copy pathmain.tf
File metadata and controls
69 lines (57 loc) · 1.89 KB
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
data "azurerm_subnet" "lookup" {
count = var.subnet_id == "" ? 1 : 0
name = var.subnet_name
virtual_network_name = var.vnet_name
resource_group_name = var.resource_group_name
}
locals {
subnet_id = var.subnet_id != "" ? var.subnet_id : data.azurerm_subnet.lookup[0].id
}
resource "azurerm_network_interface" "this" {
name = "${var.name}-nic"
location = var.location
resource_group_name = var.resource_group_name
ip_configuration {
name = "internal"
subnet_id = local.subnet_id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = var.create_public_ip ? azurerm_public_ip.this[0].id : null
}
tags = var.tags
}
resource "azurerm_public_ip" "this" {
count = var.create_public_ip ? 1 : 0
name = "${var.name}-pip"
location = var.location
resource_group_name = var.resource_group_name
allocation_method = "Static"
sku = "Standard"
tags = var.tags
}
resource "azurerm_linux_virtual_machine" "this" {
name = var.name
location = var.location
resource_group_name = var.resource_group_name
size = var.vm_size
admin_username = var.admin_username
disable_password_authentication = true
network_interface_ids = [
azurerm_network_interface.this.id,
]
admin_ssh_key {
username = var.admin_username
public_key = var.ssh_public_key
}
os_disk {
caching = "ReadWrite"
storage_account_type = var.os_disk_type
disk_size_gb = var.os_disk_size_gb
}
source_image_reference {
publisher = var.image_publisher
offer = var.image_offer
sku = var.image_sku
version = var.image_version
}
tags = var.tags
}