-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathself-managed-worker.tf
67 lines (56 loc) · 2.34 KB
/
self-managed-worker.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
resource "azurerm_public_ip" "worker_public_ip" {
count = var.deploy_self_managed_worker == true ? 1 : 0
name = "${var.friendly_name_prefix}-worker"
location = azurerm_resource_group.boundary-rg.location
resource_group_name = azurerm_resource_group.boundary-rg.name
allocation_method = "Static"
sku = "Standard"
}
resource "azurerm_network_interface" "boundary_worker_nic" {
count = var.deploy_self_managed_worker == true ? 1 : 0
name = "${var.friendly_name_prefix}-worker"
location = azurerm_resource_group.boundary-rg.location
resource_group_name = azurerm_resource_group.boundary-rg.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.boundary_worker_subnet[0].id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.worker_public_ip[0].id
}
}
#------------------------------------------------------------------------------
# Custom Data (cloud-init) arguments
#------------------------------------------------------------------------------
locals {
custom_data_args = {
hcp_boundary_cluster_id = var.hcp_boundary_cluster_id
worker_public_address = azurerm_public_ip.worker_public_ip[0].ip_address
boundary_worker_version = var.boundary_worker_version
}
}
resource "azurerm_linux_virtual_machine" "boundary_worker" {
count = var.deploy_self_managed_worker == true ? 1 : 0
name = "${var.friendly_name_prefix}-boundary-worker"
resource_group_name = azurerm_resource_group.boundary-rg.name
location = azurerm_resource_group.boundary-rg.location
size = "Standard_D1_v2"
admin_username = var.ssh_target_username
network_interface_ids = [
azurerm_network_interface.boundary_worker_nic[0].id,
]
custom_data = base64encode(templatefile("${path.module}/templates/worker_custom_data.sh.tpl", local.custom_data_args))
admin_ssh_key {
username = var.ssh_target_username
public_key = file(var.ssh_public_key)
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-focal-daily"
sku = "20_04-daily-lts"
version = "latest"
}
}