Skip to content

Commit e2f58bf

Browse files
feat: use extension to provision Gateway (#4)
1 parent b8441f5 commit e2f58bf

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

main.tf

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,34 @@ 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"
5259

53-
custom_data = base64encode(<<-EOF
54-
#!/bin/bash
55-
set -e
60+
settings = jsonencode({
61+
script = base64encode(<<-SCRIPT
62+
#!/bin/bash
63+
set -euo pipefail
5664
57-
sudo apt-get update
58-
sudo apt-get install -y curl
65+
# Export environment variables for the installation script
66+
export FIREZONE_TOKEN="${var.firezone_token}"
67+
export FIREZONE_VERSION="${var.firezone_version}"
68+
export FIREZONE_NAME="${var.firezone_name}"
69+
export FIREZONE_ID="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)"
70+
export FIREZONE_API_URL="${var.firezone_api_url}"
5971
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)
72+
# Download and execute the Firezone installation script
73+
# The extension handler will retry this automatically if it fails
74+
curl -fsSL https://raw.githubusercontent.com/firezone/firezone/main/scripts/gateway-systemd-install.sh | bash
6675
67-
EOF
68-
)
76+
echo "Firezone Gateway installation completed successfully"
77+
SCRIPT
78+
)
79+
})
6980
}
7081

7182
tags = var.extra_tags

0 commit comments

Comments
 (0)