Edges API
Edges represent relationships between nodes in Infracast's infrastructure graph. An edge between a security group and an EC2 instance means the instance is a member of that group. An edge between a load balancer and an instance means traffic routes from the LB to the instance. Edges are how Infracast understands network paths, trust relationships, and attack surface.
Endpoints
| Method | Path | Description | Permission |
|---|---|---|---|
| GET | /api/v1/tenants/{tenantID}/edges | List edges | nodes:read |
| POST | /api/v1/tenants/{tenantID}/edges | Create an edge | jobs:create |
List Edges
GET /api/v1/tenants/{tenantID}/edges
Returns a paginated list of edges in the infrastructure graph.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | int | Number of results to return (default: 50, max: 500) |
cursor | string | Pagination cursor from previous response |
source_id | string | Filter edges where source node ID matches |
target_id | string | Filter edges where target node ID matches |
type | string | Filter by edge type (e.g., MEMBER_OF) |
Example Request
curl -H "Authorization: Bearer $TOKEN" \
"https://api.infracast.io/api/v1/tenants/acme-corp/edges?limit=50"
Example Response
{
"items": [
{
"id": "edge-abc123",
"tenant_id": "acme-corp",
"source_id": "aws:us-east-1:aws.ec2.instance:i-0abc123def456789a",
"target_id": "aws:us-east-1:aws.ec2.security_group:sg-0abc123",
"type": "MEMBER_OF",
"properties": {},
"created_at": "2024-03-16T08:30:00Z"
},
{
"id": "edge-def456",
"tenant_id": "acme-corp",
"source_id": "aws:us-east-1:aws.elbv2.load_balancer:arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/prod-alb/0abc123",
"target_id": "aws:us-east-1:aws.ec2.instance:i-0abc123def456789a",
"type": "ROUTES_TO",
"properties": {
"port": "443",
"protocol": "HTTPS"
},
"created_at": "2024-03-16T08:30:00Z"
},
{
"id": "edge-ghi789",
"tenant_id": "acme-corp",
"source_id": "aws:us-east-1:aws.ec2.instance:i-0abc123def456789a",
"target_id": "aws:us-east-1:aws.rds.db_instance:prod-postgres",
"type": "CONNECTS_TO",
"properties": {
"port": "5432",
"protocol": "TCP"
},
"created_at": "2024-03-16T08:30:00Z"
}
],
"total": 18340,
"limit": 50,
"next_cursor": "eyJpZCI6ImVkZ2UtZ2hpNzg5In0="
}
Edge Types
Infracast uses edge types to describe the nature of the relationship between two nodes:
Network & Traffic Edges
| Edge Type | Description | Example |
|---|---|---|
ROUTES_TO | Traffic is routed from source to target | ALB → EC2 instance |
CONNECTS_TO | Application-level connection (port/protocol) | EC2 → RDS database |
EXPOSES | Source exposes target to a network | Internet Gateway → Public subnet |
ALLOWS_TRAFFIC_FROM | Source security rule permits traffic from target | Security group → CIDR range |
Identity & Access Edges
| Edge Type | Description | Example |
|---|---|---|
MEMBER_OF | Resource belongs to a group/cluster | EC2 → Security group |
ASSUMES_ROLE | Entity can assume an IAM role | EC2 instance profile → IAM role |
HAS_POLICY | IAM entity has an attached policy | IAM role → IAM policy |
GRANTED_BY | Permission is granted through this edge | IAM user → IAM group |
Infrastructure Relationship Edges
| Edge Type | Description | Example |
|---|---|---|
CONTAINS | Parent resource contains child resource | VPC → Subnet |
DEPLOYED_IN | Resource is deployed within a container | EC2 → Subnet |
ATTACHED_TO | Resource is physically/logically attached | EBS volume → EC2 instance |
MANAGED_BY | Resource is managed by another (e.g., auto scaling) | EC2 → Auto Scaling Group |
REPLICATES_TO | Data replication relationship | RDS primary → RDS replica |
BACKED_UP_TO | Backup destination relationship | RDS → S3 backup bucket |
Kubernetes Edges
| Edge Type | Description | Example |
|---|---|---|
RUNS_ON | Pod runs on a node | Pod → K8s Node |
EXPOSES_SERVICE | Deployment exposes through a service | Deployment → Service |
BOUND_TO | Role binding relationship | ServiceAccount → ClusterRole |
Graph Traversal and Network Paths
Edges are the foundation of Infracast's network path analysis. The Path Tracer uses edges to determine if a network path exists between any two nodes:
# Trace a network path
POST /api/v1/tenants/{tenantID}/pathtracer/trace
{
"source_node_id": "aws:us-east-1:aws.ec2.instance:i-0abc123def456789a",
"destination_cidr": "0.0.0.0/0",
"port": 22,
"protocol": "tcp"
}
Response shows the complete path (sequence of edges) from source to destination:
{
"reachable": true,
"path": [
{
"from": "aws:us-east-1:aws.ec2.instance:i-0abc123def456789a",
"to": "aws:us-east-1:aws.ec2.security_group:sg-0abc123",
"edge_type": "MEMBER_OF"
},
{
"from": "aws:us-east-1:aws.ec2.security_group:sg-0abc123",
"to": "0.0.0.0/0",
"edge_type": "ALLOWS_TRAFFIC_FROM",
"detail": "Inbound rule: port 22, protocol TCP, source 0.0.0.0/0"
}
],
"finding": "Instance is reachable from the internet on port 22 (SSH)"
}
This path finding capability is what makes compliance rules like CIS-AWS-5.2 (no SSH from internet) accurate — Infracast traces actual reachability, not just security group rules in isolation.
Graph Topology
Beyond listing individual edges, you can retrieve the full graph topology for visualization:
# Clustered topology (grouped by VPC/region)
GET /api/v1/tenants/{tenantID}/graph/clustered
# Full topology (all nodes and edges)
GET /api/v1/tenants/{tenantID}/graph/full
# Lightweight topology summary for rendering
GET /api/v1/tenants/{tenantID}/graph/topology
Create an Edge (Manual)
For resources not discovered automatically (e.g., on-premises systems connected via VPN), you can create edges manually:
POST /api/v1/tenants/{tenantID}/edges
{
"source_id": "aws:us-east-1:aws.ec2.vpn_gateway:vgw-0abc123",
"target_id": "on-prem:datacenter-east:network:10.200.0.0/16",
"type": "CONNECTS_TO",
"properties": {
"protocol": "IPSec",
"tunnel": "VPN"
}
}
Pagination with Cursor
The edges endpoint uses cursor-based pagination for efficient traversal of large graphs:
# First page
GET /api/v1/tenants/acme-corp/edges?limit=100
# Next page (use cursor from previous response)
GET /api/v1/tenants/acme-corp/edges?limit=100&cursor=eyJpZCI6ImVkZ2UtZ2hpNzg5In0=
For full graph export, continue paginating until next_cursor is absent from the response. A tenant with 5,000 nodes typically has 15,000–25,000 edges.
Next Steps
- Nodes API — Nodes that edges connect
- Findings API — Compliance violations involving node relationships
- Discovery Jobs API — How edges are populated automatically