Skip to main content

Redundant BGP Sessions for Workers

This guide demonstrates how to configure redundant BGP sessions across multiple worker nodes using the NetActuate Terraform provider. Redundant sessions ensure high availability for your anycast or BGP-based services.

Overview

By establishing BGP sessions on multiple worker nodes in different locations, you create redundancy. If one node or location becomes unavailable, traffic automatically routes to the remaining healthy nodes.

Prerequisites

  • Terraform v1.0+ with the NetActuate provider configured
  • A NetActuate API key with BGP permissions
  • Your own ASN or a NetActuate-assigned ASN
  • IP prefix(es) to advertise

Terraform Configuration

Variables

variable "netactuate_api_key" {
type = string
sensitive = true
}

variable "bgp_asn" {
type = number
description = "Your BGP ASN"
}

variable "worker_locations" {
type = list(string)
description = "Locations for worker nodes"
default = ["ashburn", "losangeles", "amsterdam"]
}

variable "worker_plan" {
type = string
default = "VR2048x2x40"
}

variable "worker_image" {
type = string
default = "ubuntu-24.04"
}

Provider

terraform {
required_providers {
netactuate = {
source = "netactuate/netactuate"
version = "~> 1.0"
}
}
}

provider "netactuate" {
api_key = var.netactuate_api_key
}

Worker Nodes

resource "netactuate_server" "worker" {
count = length(var.worker_locations)
hostname = "bgp-worker-${var.worker_locations[count.index]}"
plan = var.worker_plan
location = var.worker_locations[count.index]
image = var.worker_image

tags = {
role = "bgp-worker"
}
}

BGP Sessions

resource "netactuate_bgp_session" "worker" {
count = length(var.worker_locations)
server_id = netactuate_server.worker[count.index].id
asn = var.bgp_asn
neighbor_ip = netactuate_server.worker[count.index].ip_address
}

Outputs

output "worker_ips" {
value = {
for i, server in netactuate_server.worker :
var.worker_locations[i] => server.ip_address
}
}

output "bgp_session_ids" {
value = [for session in netactuate_bgp_session.worker : session.id]
}

Deployment

  1. Initialize the configuration:

    terraform init
  2. Review the plan:

    terraform plan
  3. Apply the configuration:

    terraform apply

Verifying Sessions

After deployment, verify your BGP sessions are established:

curl -H "Authorization: Bearer $NETACTUATE_API_KEY" \
"https://api.netactuate.com/api/v2/bgp/sessions"

Each session should show a status of established once the peering is active.

Scaling Workers

To add a new location, append it to the worker_locations variable and run terraform apply. To remove a location, remove it from the list and apply. Terraform handles provisioning and cleanup automatically.

Need Help?

If you need assistance with BGP configuration, visit our support page.