Prerequisites
- A WireGuard Interface on a Network, as in the WireGuard Interface Quick Start. This page uses the interface
c788eb40-a4c0-4bf5-8f84-976027960f8e. - An Edge Compute function and the
telnyx-edgeCLI, as in the Edge Compute Quick Start.
Create the Agent Gateway
SendPOST /v2/agent_gateways with the WireGuard Interface’s id:
pending, with no gateway_url yet. network_id is the WireGuard Interface’s Network.
Wait for the Gateway
PollGET /v2/agent_gateways/{id} until status is ready. The instance joins the WireGuard Interface as a peer named agw-32ce035d-3165-4031-b1a7-a7c0c259590a, which puts the interface in provisioning again. The instance is ready once the interface is provisioned and the instance answers through the tunnel. Here that took 172 seconds. gateway_url is its address on the interface:
Issue a Key
The instance refuses a request without a key. SendPOST /v2/agent_gateways/{id}/keys with a name for the agent that holds it:
key, and no later response returns it:
Connect an Agent
An agent on Edge Compute reaches the instance through a network binding to the instance’s WireGuard Interface. In the function’sfunc.toml, bind the interface and set the instance’s gateway_url:
func.toml
Workstation
gateway_url through the binding, with the key:
index.ts
Workstation
Workstation
Output
support-agent.
Delete the Agent Gateway
DELETE /v2/agent_gateways/{id} returns the instance deleting. The gateway stops answering at once, and seconds later GET /v2/agent_gateways/{id} returns 404.