Skip to content

Commit 3089686

Browse files
feat: use extension to provision Gateway
1 parent 344ac64 commit 3089686

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
@@ -38,23 +38,37 @@ resource "azurerm_orchestrated_virtual_machine_scale_set" "firezone" {
3838
public_key = var.admin_ssh_key
3939
}
4040
}
41+
}
42+
43+
extension {
44+
name = "firezone-gateway-install"
45+
publisher = "Microsoft.Azure.Extensions"
46+
type = "CustomScript"
47+
type_handler_version = "2.1"
48+
49+
settings = jsonencode({
50+
script = base64encode(<<-SCRIPT
51+
#!/bin/bash
52+
set -euo pipefail
4153
42-
custom_data = base64encode(<<-EOF
43-
#!/bin/bash
44-
set -e
54+
sudo apt-get update
55+
sudo apt-get install -y curl
4556
46-
sudo apt-get update
47-
sudo apt-get install -y curl
57+
# Export environment variables for the installation script
58+
export FIREZONE_TOKEN="${var.firezone_token}"
59+
export FIREZONE_VERSION="${var.firezone_version}"
60+
export FIREZONE_NAME="${var.firezone_name}"
61+
export FIREZONE_ID="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)"
62+
export FIREZONE_API_URL="${var.firezone_api_url}"
4863
49-
FIREZONE_TOKEN="${var.firezone_token}" \
50-
FIREZONE_VERSION="${var.firezone_version}" \
51-
FIREZONE_NAME="${var.firezone_name}" \
52-
FIREZONE_ID="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)" \
53-
FIREZONE_API_URL="${var.firezone_api_url}" \
54-
bash <(curl -fsSL https://raw.githubusercontent.com/firezone/firezone/main/scripts/gateway-systemd-install.sh)
64+
# Download and execute the Firezone installation script
65+
# The extension handler will retry this automatically if it fails
66+
curl -fsSL https://raw.githubusercontent.com/firezone/firezone/main/scripts/gateway-systemd-install.sh | bash
5567
56-
EOF
57-
)
68+
echo "Firezone Gateway installation completed successfully"
69+
SCRIPT
70+
)
71+
})
5872
}
5973

6074
tags = var.extra_tags

0 commit comments

Comments
 (0)