Azure
Set up and deploy a Granica Admin Server on Microsoft Azure using Terraform.
This guide will help you set up and tear down a Granica Admin Server on Azure.
Prerequisites
If you are working in Azure Cloud Shell you must be logged in as Owner. If you are running from your laptop you will need Azure CLI credentials with Owner access on the subscription.
- An Azure subscription with the Owner role (needed to create the managed identity and assign RBAC roles).
Azure Bastion and the NAT gateway are billed continuously (per hour plus data) from creation until destroy, whether or not the admin server is in use.
Instructions
1. Register Azure resource providers
az login --tenant <your-tenant-id>
az account set --subscription <your-subscription-id>
az provider register --namespace Microsoft.Compute
az provider register --namespace Microsoft.Network
az provider register --namespace Microsoft.Storage
az provider register --namespace Microsoft.ManagedIdentity
az provider register --namespace Microsoft.Authorization
az provider register --namespace Microsoft.Resources
az provider register --namespace Microsoft.ContainerService
az provider register --namespace Microsoft.DBforPostgreSQL
az provider register --namespace Microsoft.ServiceBus
az provider register --namespace Microsoft.OperationalInsights2. Install Terraform
Install Terraform in Azure Cloud Shell or on your laptop, then clone the Granica Setup repo:
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
mkdir ~/bin
ln -s ~/.tfenv/bin/* ~/bin/
export PATH="$HOME/.tfenv/bin:$PATH"
tfenv install 1.13.4
tfenv use 1.13.4
terraform --version
git clone https://github.com/granica-ai/granica-setup.git
cd granica-setup/azure3. Create a storage account for Terraform state
az group create --name granica-tfstate-rg --location <region>
az storage account create --name <account-name> --resource-group granica-tfstate-rg \
--location <region> --sku Standard_LRS --encryption-services blob
az storage container create --name tfstate --account-name <account-name>4. Configure backend.conf
resource_group_name = "granica-tfstate-rg"
storage_account_name = "<account-name>"
container_name = "tfstate"
key = "<your-unique-key>/terraform.tfstate"5. Configure terraform.tfvars
subscription_id = "your-subscription-id" # az account show --query id -o tsv
region = "eastus2"
package_url = "https://granica.ai/granica.rpm"
server_name = "CHANGE_ME"Optional settings (see terraform.tfvars.sample):
vm_size = "Standard_D2ads_v7" # Admin server VM size (default: Standard_D2ads_v7)
public_ip_enabled = true # Give the admin server a public IP (dev/test only)
bastion_enabled = false # Bastion is created by default; disable only for dev/test with public_ip_enabled5.1 (Optional) Existing VNet
Set existing_vnet_id to deploy into an existing VNet instead of creating a new one. In existing-VNet mode the module does not create subnets, so you must also pass every subnet the deployment needs:
existing_vnet_id = "/subscriptions/.../virtualNetworks/my-vnet"
existing_subnet_id = "/subscriptions/.../virtualNetworks/my-vnet/subnets/admin"
existing_aks_system_subnet_id = "/subscriptions/.../virtualNetworks/my-vnet/subnets/aks-system"
existing_aks_workload_subnet_id = "/subscriptions/.../virtualNetworks/my-vnet/subnets/aks-workload"
existing_postgres_subnet_id = "/subscriptions/.../virtualNetworks/my-vnet/subnets/postgres"6. Deploy the admin server
terraform init -backend-config=backend.conf
terraform apply7. Log in to the admin server
By default the admin server has no public IP and is reached through Azure Bastion, so the VM stays private. terraform apply prints the exact connect command.
Default (Bastion):
az network bastion ssh \
--resource-group granica-{server_name}-rg \
--name granica-bastion-{server_name} \
--target-resource-id $(terraform output -raw instance_id) \
--auth-type AAD
# server_name is what you provided in the terraform.tfvars filePublic IP (public_ip_enabled = true, dev/test only): the server gets a public IP and an SSH rule, so you can connect directly:
az ssh vm --resource-group granica-{server_name}-rg --name granica-admin-server-{server_name}Existing VNet (existing_vnet_id set): no Bastion and no public IP are created, so Terraform does not provision any access path to the admin server. Supply your own connectivity into the VNet — an existing Bastion host, a VPN gateway, or VNet peering from a network you can reach — then SSH to the VM's private IP as the granica user (AAD login works over your own route). The ssh_command output reflects this.
Once connected:
sudo su - granica # Use the granica user to run granica commands
# The Granica package takes around 10-15 minutes to install.
# Monitor progress:
tail -f /var/log/granica-startup.log
granica --help
granica deploy --var-file config.tfvars
# Cluster deployment takes around 10-15 minutes.Teardown
Destroy in the reverse order of creation. The Granica workload uses this Terraform state's resource group, subnets, NAT gateway associations, admin managed identity, and access path, so it must go first.
1. Destroy the Granica workload
On the admin server:
sudo su - granica
granica destroy --var-file config.tfvars2. Destroy the admin server
From your workstation or Cloud Shell:
terraform destroy -var-file=terraform.tfvarsDo not run terraform destroy before the Granica workload is gone. Its subnets are still in use by the AKS nodes and Postgres, and its resource group is not empty, so the destroy will fail or leave orphaned resources behind.
GCP
Set up and deploy a Granica Admin Server on Google Cloud Platform using Terraform.
Table Compaction
Consolidate small files into optimally sized ones to reduce metadata overhead and speed up queries.