API: VPCs, Subnets & Security Groups
VPC Endpoints
| Method | Path | Description |
|---|
| POST | /v1/vpcs | Create a VPC |
| GET | /v1/vpcs | List all VPCs |
| GET | /v1/vpcs/{id} | Get VPC details |
| DELETE | /v1/vpcs/{id} | Delete a VPC |
### Create VPC
POST /v1/vpcs
{
"metadata": {"name": "production"},
"spec": {"cidr": "10.0.0.0/16"}
}
Response (201)
{
"id": "vpc-a1b2c3",
"metadata": {"name": "production", "created_at": "2025-01-15T10:00:00Z"},
"spec": {"cidr": "10.0.0.0/16"},
"status": {"state": "active", "subnet_count": 0}
}
Subnet Endpoints
| Method | Path | Description |
|---|
| POST | /v1/subnets | Create a subnet |
| GET | /v1/subnets | List subnets (filter by ?vpc_id=) |
| GET | /v1/subnets/{id} | Get subnet details |
| DELETE | /v1/subnets/{id} | Delete a subnet |
### Create Subnet
{
"metadata": {"name": "web-tier"},
"spec": {
"vpc_id": "vpc-a1b2c3",
"cidr": "10.0.1.0/24",
"availability_zone": "fsn1-dc14"
}
}
Security Group Endpoints
| Method | Path | Description |
|---|
| POST | /v1/security-groups | Create a security group |
| GET | /v1/security-groups | List security groups |
| GET | /v1/security-groups/{id} | Get details |
| DELETE | /v1/security-groups/{id} | Delete |
### Create Security Group
{
"metadata": {"name": "web-sg"},
"spec": {
"vpc_id": "vpc-a1b2c3",
"rules": [
{"direction": "ingress", "protocol": "tcp", "port": 80, "cidr": "0.0.0.0/0"},
{"direction": "ingress", "protocol": "tcp", "port": 443, "cidr": "0.0.0.0/0"},
{"direction": "ingress", "protocol": "tcp", "port": 22, "cidr": "10.0.0.0/16"},
{"direction": "egress", "protocol": "all", "port": 0, "cidr": "0.0.0.0/0"}
]
}
}
Network Setup Example
# 1. Create VPC
curl -X POST $API/v1/vpcs -H "$AUTH" -H "$CT" \
-d '{"metadata":{"name":"prod"},"spec":{"cidr":"10.0.0.0/16"}}'
2. Create Subnet
curl -X POST $API/v1/subnets -H "$AUTH" -H "$CT" \
-d '{"metadata":{"name":"web"},"spec":{"vpc_id":"vpc-abc","cidr":"10.0.1.0/24"}}'
3. Create Security Group
curl -X POST $API/v1/security-groups -H "$AUTH" -H "$CT" \
-d '{"metadata":{"name":"web-sg"},"spec":{"vpc_id":"vpc-abc","rules":[...]}}'