Skip to content

Commit d9963a3

Browse files
feat: use extension to provision Gateway
1 parent 598916e commit d9963a3

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

main.tf

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,37 @@ resource "azurerm_orchestrated_virtual_machine_scale_set" "firezone" {
4949
public_key = var.admin_ssh_key
5050
}
5151
}
52+
}
53+
54+
extension {
55+
name = "firezone-gateway-install"
56+
publisher = "Microsoft.Azure.Extensions"
57+
type = "CustomScript"
58+
type_handler_version = "2.1"
59+
60+
settings = jsonencode({
61+
script = base64encode(<<-SCRIPT
62+
#!/bin/bash
63+
set -euo pipefail
5264
53-
custom_data = base64encode(<<-EOF
54-
#!/bin/bash
55-
set -e
65+
sudo apt-get update
66+
sudo apt-get install -y curl
5667
57-
sudo apt-get update
58-
sudo apt-get install -y curl
68+
# Export environment variables for the installation script
69+
export FIREZONE_TOKEN="${var.firezone_token}"
70+
export FIREZONE_VERSION="${var.firezone_version}"
71+
export FIREZONE_NAME="${var.firezone_name}"
72+
export FIREZONE_ID="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)"
73+
export FIREZONE_API_URL="${var.firezone_api_url}"
5974
60-
FIREZONE_TOKEN="${var.firezone_token}" \
61-
FIREZONE_VERSION="${var.firezone_version}" \
62-
FIREZONE_NAME="${var.firezone_name}" \
63-
FIREZONE_ID="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)" \
64-
FIREZONE_API_URL="${var.firezone_api_url}" \
65-
bash <(curl -fsSL https://raw.githubusercontent.com/firezone/firezone/main/scripts/gateway-systemd-install.sh)
75+
# Download and execute the Firezone installation script
76+
# The extension handler will retry this automatically if it fails
77+
curl -fsSL https://raw.githubusercontent.com/firezone/firezone/main/scripts/gateway-systemd-install.sh | bash
6678
67-
EOF
68-
)
79+
echo "Firezone Gateway installation completed successfully"
80+
SCRIPT
81+
)
82+
})
6983
}
7084

7185
tags = var.extra_tags

0 commit comments

Comments
 (0)