Generate interactive network topology visualizations for your Cloudflare Zero Trust infrastructure. See your tunnels, access applications, policies, identity providers, and private networks as a beautiful, interactive graph.
Inspired by tailscale-network-topology-mapper
| Resource | Visualization |
|---|---|
| π΅ Tunnels | Cloudflare Tunnels with connector status, ingress rules, origin IPs |
| π’ Access Applications | Self-hosted apps, SaaS apps with domains and session duration |
| π‘ Access Policies | Allow/deny/bypass rules with include/exclude/require logic |
| π Access Groups | Reusable identity groups with member criteria |
| π£ Virtual Networks | Private network segmentation for tunnel routing |
| π΄ WARP Devices | Enrolled devices with user info and last seen status |
| π Identity Providers | Okta, Azure AD, Google, GitHub, and other IdPs |
| π‘οΈ Gateway Rules | DNS and HTTP firewall policies (optional) |
- Search: Find nodes by name, domain, or type
- Filter: Toggle visibility by resource type
- Zoom & Pan: Navigate large topologies
- Drag: Rearrange nodes manually
- Tooltips: Hover for detailed configuration info
- Dark Theme: Easy on the eyes, matches Cloudflare dashboard
- Python 3.12+
- Cloudflare API Token with Zero Trust read permissions
git clone https://github.com/yourusername/cloudflare-topology.git
cd cloudflare-topology
pip install -r requirements.txtexport CLOUDFLARE_API_TOKEN="your-api-token"
export CLOUDFLARE_ACCOUNT_ID="your-account-id"π Where to find your Account ID
Your Account ID is visible in:
- The URL when logged into Cloudflare:
dash.cloudflare.com/<ACCOUNT_ID>/... - Any zone's Overview page β right sidebar under "Account ID"
- Workers & Pages β right sidebar
# Basic usage - opens in browser
python main.py
# Skip tunnel configs for faster generation
python main.py --no-tunnel-configs
# Include Gateway firewall rules
python main.py --include-gateway
# Debug mode with verbose output
python main.py --debugRun as a web service with automatic regeneration:
# Build
make build
# Run (requires env vars)
export CLOUDFLARE_API_TOKEN="your-token"
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
make run
# View at http://localhost:8080Or with docker directly:
docker build -t cloudflare-topology .
docker run -d \
--name cloudflare-topology \
-p 8080:8080 \
-e CLOUDFLARE_API_TOKEN="your-token" \
-e CLOUDFLARE_ACCOUNT_ID="your-account-id" \
cloudflare-topology| Endpoint | Method | Description |
|---|---|---|
/ |
GET | View topology visualization |
/health |
GET | Health check |
/regenerate |
POST | Trigger topology refresh |
Create a token at Cloudflare Dashboard β API Tokens:
| Permission | Scope | Used For |
|---|---|---|
| Zero Trust: Read | Account | Tunnels, virtual networks, routes |
| Access: Apps and Policies: Read | Account | Applications, policies, groups |
| Permission | Scope | Used For |
|---|---|---|
| Devices: Read | Account | WARP device enrollment |
| Gateway: Read | Account | DNS/HTTP firewall rules |
π‘οΈ Recommended: Use a Custom Token
Create a token with only the permissions you need. Avoid using Global API Keys.
- Go to API Tokens
- Click "Create Token"
- Use "Create Custom Token"
- Add the permissions listed above
- Set appropriate TTL and IP restrictions for security
| Type | Color | Shape | Description |
|---|---|---|---|
| Cloudflare | Orange | Star | Central hub node |
| Tunnel | Blue #3b82f6 |
Hexagon | Cloudflare Tunnel connectors |
| Application | Green #22c55e |
Circle | Access-protected applications |
| Policy | Yellow #eab308 |
Triangle | Access policy rules |
| Group | Orange #f97316 |
Circle | Access groups |
| Identity Provider | Cyan #06b6d4 |
Star | Okta, Azure AD, etc. |
| Virtual Network | Purple #a855f7 |
Square | Private network segments |
| Route | Lime #84cc16 |
Circle | Private network routes |
| Device | Red #ef4444 |
Diamond | WARP-enrolled devices |
| Gateway Rule | Pink #ec4899 |
Triangle | Firewall policies |
python main.py [OPTIONS]
Options:
--debug Enable verbose debug logging
--output, -o FILE Output HTML file (default: network_topology.html)
--no-browser Don't auto-open browser after generation
--no-devices Skip fetching WARP devices (faster)
--no-tunnel-configs Skip fetching detailed tunnel configurations
--include-gateway Include Gateway firewall rules
| Variable | Required | Description |
|---|---|---|
CLOUDFLARE_API_TOKEN |
β | API token with Zero Trust read permissions |
CLOUDFLARE_ACCOUNT_ID |
β | Your Cloudflare account ID |
DEBUG |
β | Set to true for debug logging |
cloudflare-topology/
βββ main.py # CLI entry point
βββ config.py # Configuration, colors, API endpoints
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container image
βββ Makefile # Build/run commands
β
βββ models/
β βββ cloudflare_data.py # Data models for all resources
β
βββ services/
β βββ cloudflare_api.py # Cloudflare API client with pagination
β βββ network_graph.py # Graph builder (nodes & edges)
β βββ renderer.py # HTML/CSS/JS visualization
β
βββ server/
β βββ server.py # Flask server for Docker
β
βββ tests/
βββ test_config.py
βββ test_models.py
βββ test_network_graph.py
# Install dev dependencies
pip install -r requirements.txt
# Run tests
make test
# or
python -m pytest tests/ -v
# Lint
make lintContributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
Apache 2.0 - see LICENSE for details.
- tailscale-network-topology-mapper - Original inspiration
- Pyvis - Python network visualization
- vis.js - JavaScript graph library
- Cloudflare - Zero Trust platform
Made with βοΈ for the Cloudflare community
