Basic Wrangler Extractor¶
Extract deployment topology from Cloudflare Workers configuration.
The basic-wrangler extractor analyzes wrangler.toml files to discover Workers, environments, service bindings, and infrastructure dependencies. It captures how your Workers deploy, not just what code they contain.
What It Extracts¶
From wrangler.toml files:
- πΉ Containers β Cloudflare Workers as deployable units
- πΉ Deployments β Environments (production, staging, preview)
- πΉ Container Instances β Deployed instances per environment
- πΉ Service Bindings β Worker-to-worker dependencies
- πΉ Infrastructure Bindings β KV, R2, D1, Durable Objects, Queues
- πΉ Relationships β Both logical (containerβcontainer) and physical (instanceβinstance)
Configuration¶
Basic Setup¶
Multiple Workers¶
extractors:
- use: extractors/builtin/basic-wrangler
inputs:
include:
- 'workers/gateway/wrangler.toml'
- 'workers/api/wrangler.toml'
- 'workers/auth/wrangler.toml'
Monorepo Pattern¶
extractors:
- use: extractors/builtin/basic-wrangler
inputs:
include: ['iac/workers/**/*.toml']
exclude: ['**/wrangler.dev.toml']
What Gets Extracted¶
Containers¶
One per wrangler.toml file:
# workers/gateway/wrangler.toml
name = "bond-math-gateway"
main = "src/index.ts"
compatibility_date = "2024-01-01"
Becomes:
{
"id": "bond-math-gateway",
"name": "bond-math-gateway",
"type": "Cloudflare Worker",
"technology": "TypeScript",
"layer": "Application",
"tags": ["cloudflare-worker"]
}
Deployments & Environments¶
Extracts all environment configurations:
# Root level = production
name = "gateway"
main = "src/index.ts"
[env.development]
name = "gateway-dev"
[env.preview]
name = "gateway-preview"
Creates 3 deployments:
production(from root)developmentpreview
Service Bindings¶
Worker-to-worker dependencies:
[[services]]
binding = "SVC_DAYCOUNT"
service = "bond-math-daycount"
environment = "production"
[[services]]
binding = "SVC_PRICING"
service = "bond-math-pricing"
environment = "production"
Creates:
- Logical relationship: gateway β daycount
- Logical relationship: gateway β pricing
- Physical relationship: productiongateway β productiondaycount
- Physical relationship: productiongateway β productionpricing
Infrastructure Bindings¶
KV Namespaces:
R2 Buckets:
D1 Databases:
Durable Objects:
[[durable_objects.bindings]]
name = "RATE_LIMITER"
class_name = "RateLimiter"
script_name = "rate-limiter-worker"
Queues:
All captured in container instance metadata.
Environment Overrides¶
Environment-specific configurations:
name = "gateway"
main = "src/index.ts"
[vars]
API_URL = "https://api.prod.example.com"
TIMEOUT = "30"
[env.development]
name = "gateway-dev"
vars = { API_URL = "https://api.dev.example.com", TIMEOUT = "5" }
[env.preview]
vars = { API_URL = "https://api.preview.example.com" }
Each environment instance gets correct vars:
production__gatewayβAPI_URL="https://api.prod...,TIMEOUT="30"development__gatewayβAPI_URL="https://api.dev...",TIMEOUT="5"preview__gatewayβAPI_URL="https://api.preview...",TIMEOUT="30"
Container Instance IDs¶
Simple pattern: {environment}__{service}
| Worker Name | Environment | Instance ID |
|---|---|---|
gateway |
production | production__gateway |
gateway |
development | development__gateway |
daycount |
production | production__daycount |
pricing-api |
staging | staging__pricing-api |
Why this pattern?
- Simple and predictable
- Easy to reference in other tools
- No deep hierarchies
- Scales to any number of services
Complete Example¶
wrangler.toml¶
name = "api-gateway"
main = "src/index.ts"
compatibility_date = "2024-01-01"
[vars]
LOG_LEVEL = "info"
INTERNAL_JWT_TTL = "90"
[[services]]
binding = "SVC_AUTH"
service = "auth-service"
environment = "production"
[[services]]
binding = "SVC_DATA"
service = "data-service"
environment = "production"
[[kv_namespaces]]
binding = "CACHE"
id = "abc123..."
[[r2_buckets]]
binding = "UPLOADS"
bucket_name = "user-uploads"
[env.development]
name = "api-gateway-dev"
vars = { LOG_LEVEL = "debug" }
[[env.development.services]]
binding = "SVC_AUTH"
service = "auth-service"
environment = "development"
[[env.development.services]]
binding = "SVC_DATA"
service = "data-service"
environment = "development"
Extracted Architecture¶
Containers (3):
api-gateway(Cloudflare Worker)auth-service(inferred from binding)data-service(inferred from binding)
Deployments (2):
productionwith 3 instancesdevelopmentwith 3 instances
Container Instances (6):
production__api-gateway(with CACHE KV, UPLOADS R2, SVC_AUTH, SVC_DATA)production__auth-serviceproduction__data-servicedevelopment__api-gateway(with SVC_AUTH, SVC_DATA)development__auth-servicedevelopment__data-service
Logical Relationships (2):
- api-gateway β auth-service
- api-gateway β data-service
Physical Relationships (4):
- productionapi-gateway β productionauth-service
- productionapi-gateway β productiondata-service
- developmentapi-gateway β developmentauth-service
- developmentapi-gateway β developmentdata-service
Combining with Code Analysis¶
Use with basic-node for complete picture:
extractors:
# Extract application code
- use: extractors/builtin/basic-node
inputs:
include: ['src/**/*.ts']
# Extract deployment topology
- use: extractors/builtin/basic-wrangler
inputs:
include: ['wrangler.toml']
Result:
- Components and actors from code annotations
- Containers and deployments from wrangler config
- Complete logical + physical architecture
Routes & Triggers¶
HTTP Routes:
Cron Triggers:
Both captured in container instance metadata.
Observability¶
Logging and monitoring configuration:
Captured as instance metadata.
Best Practices¶
β Do¶
- Keep wrangler.toml files discoverable β Use consistent naming
- Document service bindings β Clear binding names help diagrams
- Use environment overrides β Keep config DRY
- Explicit environments β Define all environments you deploy to
- Combine with code analysis β Use basic-node for complete view
β Don't¶
- Spread configuration β Keep related workers in discoverable locations
- Use cryptic names β
SVC_1worse thanSVC_AUTH - Forget includes β Ensure patterns match your files
- Mix production secrets β basic-wrangler extracts vars (use secrets for sensitive data)
Troubleshooting¶
Workers Not Showing Up¶
Check:
- wrangler.toml file has
namefield - File matches
includepatterns - File doesn't match
excludepatterns - TOML syntax is valid
Service Bindings Missing¶
Check:
- Using
[[services]]array syntax bindingandservicefields present- Service name matches target worker's
name
Environments Not Created¶
Check:
- Using
[env.environment_name]syntax - Environment has deployable configuration (routes, vars, or bindings)
- Root level has content (implies production environment)
What's Next?¶
Combine with code:
- Basic Node β Add application logic
- Configuration Guide β Advanced options
Understand architecture:
- Cloudflare Requirements β Technical spec
Extend:
- Plugin Development β Custom extractors