Context & Why: Moving Away from Traditional Bastions and VPNs
Six months ago, our access architecture collapsed under its own operational weight. Our team of 45 engineers relied on two OpenVPN gateways and a pair of dual-homed SSH bastion hosts to reach 12 private PostgreSQL clusters and our internal Kubernetes worker nodes. Every onboarding required generating individual ed25519 key pairs, manually updating AWS security groups, and granting full CIDR-level access to entire /24 subnets.
This setup obliterated the principle of least privilege. Once connected to the client VPN, an engineer’s laptop lived directly inside the production VPC. A single compromised laptop or infected dev container gave attackers lateral access across staging and production databases. Credential rotations routinely turned into Friday afternoon fire drills. Worse, our compliance audits surfaced dozens of undocumented SSH sessions with no granular command logs.
We replaced that perimeter with HashiCorp Boundary. Traditional VPNs operate at layers 3 and 4, issuing IP leases and granting wide network visibility. Boundary operates strictly at layer 7 via identity-based access control.
It acts as an identity-aware proxy. Engineers authenticate against an existing IdP such as Okta or GitHub, then request a specific target like an internal PostgreSQL port. Boundary brokers an encrypted, mutually authenticated TCP tunnel straight to that service. The user never sees the private subnet.
Carving out dedicated subnets for Boundary workers required careful network planning across three AWS regions. I used the Subnet Calculator on ToolCraft to divide our 10.0.0.0/16 VPC into clean /28 worker tiers without IP overlap. Because ToolCraft runs all subnet math 100% client-side in your browser, no private IP layouts or routing topologies leave your workstation.
Installation: Deploying the Controller and Worker Architecture
Boundary splits operations between two core binaries. The Controller handles authentication, state management, and policy enforcement via PostgreSQL. The Worker establishes downstream proxy sessions directly to targets inside private subnets. Crucially, workers dial outbound to controllers over port 9201. You never need to open inbound firewall holes into your secure database subnets.
We deployed our controller pair on Ubuntu 22.04 LTS behind an internal Network Load Balancer (NLB). Here is how to bootstrap a minimal, production-ready controller and worker setup.
1. Initializing the Database and Boundary Binaries
Install the HashiCorp repository and binaries on your controller host:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update && sudo apt-get install -y boundary postgresql-client
2. Configuring the Controller
The controller needs an AEAD root key for cryptographic token signing and a dedicated PostgreSQL connection. Save this configuration as /etc/boundary/controller.hcl:
disable_mlock = true
controller {
name = "primary-controller-01"
description = "Main control plane for internal infrastructure"
database {
url = "postgresql://boundary_user:[email protected]:5432/boundary?sslmode=disable"
}
}
listener "tcp" {
purpose = "api"
address = "0.0.0.0:9200"
tls_disable = true
}
listener "tcp" {
purpose = "cluster"
address = "0.0.0.0:9201"
tls_disable = true
}
kms "aead" {
purpose = "root"
aead_type = "aes-gcm"
key = "s3cr3tk3y1234567890123456789012"
key_id = "global_root"
}
kms "aead" {
purpose = "worker-auth"
aead_type = "aes-gcm"
key = "s3cr3tk3y1234567890123456789012"
key_id = "global_worker_auth"
}
Initialize the database schema, then start the service:
boundary database init -config /etc/boundary/controller.hcl
sudo systemctl enable --now boundary-controller
3. Configuring the Boundary Worker
Place workers inside the private subnets holding your targets. Workers must reach both the controller cluster port (9201) and the target ports (e.g., PostgreSQL on 5432 or SSH on 22). Here is a tested worker definition for /etc/boundary/worker.hcl:
disable_mlock = true
worker {
name = "prod-worker-us-east-1a"
description = "Worker inside RDS private subnet"
controllers = [
"10.0.1.10:9201"
]
public_addr = "10.0.2.15"
}
listener "tcp" {
purpose = "proxy"
address = "0.0.0.0:9202"
tls_disable = true
}
kms "aead" {
purpose = "worker-auth"
aead_type = "aes-gcm"
key = "s3cr3tk3y1234567890123456789012"
key_id = "global_worker_auth"
}
Launch the worker daemon via systemd or run it directly to verify connectivity:
sudo boundary server -config /etc/boundary/worker.hcl
Configuration: Granular Scopes, Targets, and Role-Based Access
Boundary structures access using a strict hierarchy: Global > Organization > Project > Targets. Getting this hierarchy right is critical. It defines your security boundaries and keeps day-to-day navigation clean for developers.
1. Setting Up Scopes and Host Catalogs
Authenticate with the recovery login token generated during the database init step:
export BOUNDARY_ADDR="http://127.0.0.1:9200"
boundary authenticate password -login-name admin -password <initial-admin-token>
Create an organization scope for Engineering, a project scope for Production, and a host catalog for databases:
# Create Organization
ORG_ID=$(boundary scopes create -scope-id global -name "Engineering" -format json | jq -r .item.id)
# Create Project
PROJECT_ID=$(boundary scopes create -scope-id $ORG_ID -name "Production" -format json | jq -r .item.id)
# Create Static Host Catalog
CATALOG_ID=$(boundary host-catalogs create static -scope-id $PROJECT_ID -name "Core-Databases" -format json | jq -r .item.id)
2. Registering PostgreSQL and SSH Targets
Add host endpoints to the catalog, bundle them into a host set, and define your connection target:
# Add host entry for PostgreSQL primary
HOST_ID=$(boundary hosts create static -host-catalog-id $CATALOG_ID -name "pg-primary" -address "10.0.5.42" -format json | jq -r .item.id)
# Group host into a host set
HOST_SET_ID=$(boundary host-sets create static -host-catalog-id $CATALOG_ID -name "pg-cluster" -format json | jq -r .item.id)
boundary host-sets add-hosts -id $HOST_SET_ID -host $HOST_ID
# Define target with a 30-minute session TTL (1800 seconds)
TARGET_ID=$(boundary targets create tcp \
-scope-id $PROJECT_ID \
-name "Production-PostgreSQL" \
-default-port 5432 \
-host-set $HOST_SET_ID \
-session-max-seconds 1800 \
-format json | jq -r .item.id)
Validating complex role policies and JSON manifests across dozens of targets gets messy quickly. I use the JSON Formatter & Validator on ToolCraft to inspect payload schemas before pushing them through Terraform. If you need 32-character service passwords or initial database credentials during setup, the client-side Password Generator on ToolCraft produces clean high-entropy strings directly in memory without exposing tokens over the wire.
3. Assigning User Roles and Permissions
Grant developers permission to authorize proxy sessions without letting them modify targets or catalogs:
# Grant authorize-session and read permissions to the database team
boundary roles create -scope-id $PROJECT_ID \
-name "database-operators" \
-grant-strings "id=${TARGET_ID};actions=authorize-session,read"
Verification & Monitoring: Establishing Sessions and Auditing
Engineers no longer need local SSH keys, bastion jump scripts, or open VPN tunnels. Access flows entirely through the Boundary CLI or desktop app.
Connecting to the Target from a Developer Workstation
An engineer signs in via Okta and connects to PostgreSQL with a single command:
boundary authenticate
boundary connect postgres -target-id ttcp_AbCd1234Efg -dbname analytics_db -username analyst_read
Boundary allocates a local loopback port (such as 127.0.0.1:58432), opens an encrypted mTLS tunnel to the worker, and invokes psql automatically. The engineer queries tables normally. The underlying AWS private IP stays completely hidden.
For custom TCP traffic or SSH sessions, run Boundary in generic proxy mode:
# Open a local listening proxy to a private node
boundary connect -target-id ttcp_SshHost001
# Output:
# Proxy started! Listening on 127.0.0.1:49210
# User can now run: ssh [email protected] -p 49210
Session Auditing and Real-Time Termination
Every packet routes through the worker, giving security teams instant visibility. You can inspect active tunnels or sever suspicious connections immediately:
# List active sessions in the production scope
boundary sessions list -scope-id $PROJECT_ID
# Inspect connection metadata (IP, user ID, target, start time)
boundary sessions read -id s_9jKa982kLq
# Terminate an active session immediately
boundary sessions cancel -id s_9jKa982kLq
Boundary streams structured JSON audit logs for every authentication, session grant, and disconnect. Shipping these logs to Grafana Loki gave our compliance team an immutable audit trail showing who connected to which database, from where, and for how long. Over six months in production across 45 engineers, onboarding time dropped from 3 days to under 15 minutes, lateral network exposure dropped to zero, and we decommissioned our legacy VPN for good.
