13 views
Your coding agent is no longer one Lambda. It is a planner, a repo RAG service, a sandbox executor, a linter sidecar, and a secrets broker — often in different VPCs or accounts. Security groups and PrivateLink endpoints multiply until nobody can explain who can call what. Amazon VPC Lattice gives you a service network: register tool services, attach auth policies (IAM / SigV4), and connect clients without flattening every VPC into one flat trust domain. Use Lattice next to PrivateLink for Bedrock, Verified Permissions / Cedar, and Network Firewall egress.
⚡ TL;DR: Create a VPC Lattice service network forcoding-agent-tools. Register each tool microservice (ECS/EKS/Lambda/ALB targets). Attach auth policies so only the planner role canvpc-lattice-svcs:Invokeon sensitive tools. Associate sandbox and prod VPCs deliberately. Log access; deny by default. Related: App Runner HTTP APIs, API GW + WAF, Fargate Spot sandboxes.
Why security groups stop scaling for agents
Agent tool graphs are many-to-many:- Planner → RAG, planner → sandbox, sandbox → package mirror, linter → planner callback
- New tools appear weekly (agents invent needs)
- Tenants may need isolation at the network policy layer, not only in app code
| Connectivity | Best for | Gap for agents |
|---|---|---|
| SG + shared subnets | Small monoliths | Exploding rule sets |
| PrivateLink per tool | Stable SaaS-style APIs | N endpoints × N consumers |
| VPC Lattice service network | Many internal tools + IAM auth | Learning curve; HTTP/gRPC oriented |
| App Mesh / Istio | Deep L7 mesh features | Heavier ops |
Lattice building blocks for tool fleets
- Service network — the trust boundary (
coding-agent-tools-prod) - Services — each tool (
rag-search,sandbox-exec,lint-runner) - Target groups — IP/Lambda/ALB backends
- Auth policies — IAM policy documents on the service or network
- VPC associations — which VPCs can resolve/invoke
bash
# ✅ create service network + auth-required default
aws vpc-lattice create-service-network \
--name coding-agent-tools-prod \
--auth-type AWS_IAM \
--tags key=workload,value=coding-agent
bash
❌ Associating the entire corporate VPC “for convenience” — sandboxes should join a dedicated association with tighter policies.
# ✅ register a tool service and attach to the network
aws vpc-lattice create-service --name sandbox-exec --auth-type AWS_IAM
aws vpc-lattice create-service-network-service-association \
--service-network-identifier sn-xxxx \
--service-identifier svc-yyyy
Auth policies: planner can invoke, tools cannot freestyle
Lattice auth policies look like IAM resource policies on the service.json
// ✅ sandbox-exec service policy: only planner task role may invoke
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "PlannerOnly",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:role/coding-agent-planner-prod"
},
"Action": "vpc-lattice-svcs:Invoke",
"Resource": "*",
"Condition": {
"StringEquals": {
"vpc-lattice-svcs:RequestHeader/x-tenant-id": "${aws:PrincipalTag/tenant_id}"
}
}
}]
}
python
Application-level authorization still belongs in Verified Permissions / Cedar for fine-grained tool args. Lattice answers can this principal reach this service at all?
# ✅ client call with SigV4 to Lattice-generated service DNS
import boto3
from botocore.auth import SigV4Auth
from botocore.awsrequest import AWSRequest
import requests, os
def invoke_tool(service_dns: str, path: str, body: bytes, tenant_id: str):
url = f"https://{service_dns}{path}"
headers = {"Content-Type": "application/json", "x-tenant-id": tenant_id}
request = AWSRequest(method="POST", url=url, data=body, headers=headers)
SigV4Auth(boto3.Session().get_credentials(), "vpc-lattice-svcs", os.environ["AWS_REGION"]).add_auth(request)
# ✅ signed headers required — ❌ bare curl without SigV4 will 403
return requests.post(url, data=body, headers=dict(request.headers), timeout=30)
Topology patterns that work
Pattern A — Single network, prod toolsPlanner VPC + tool VPCs associate to one network. Sandboxes are targets with short-lived tasks (Fargate Spot). Pattern B — Split networks
coding-agent-tools-prod and coding-agent-tools-sandbox separate. Agents promote configs, not network trust.
Pattern C — Cross-account toolsShared RAG account registers services; consumer accounts associate VPCs with RAM/Lattice sharing. Planner roles in tenant accounts get explicit principals in auth policies.
typescript
// ✅ CDK sketch: Lattice service + IAM auth for a tool
import * as lattice from "aws-cdk-lib/aws-vpclattice";
// Use L1 Cfn* constructs matching your CDK version for service network / service
// Enforce authType AWS_IAM and tag workload=coding-agent on every resource
Observability and fail-closed defaults
| Control | Setting |
|---|---|
| Auth type | AWS_IAM (not NONE) on prod services |
| Access logs | Enable to S3/Firehose — who invoked which tool |
| Idle timeouts | Match tool SLOs; sandbox exec may need longer |
| Egress | Network Firewall still governs internet from sandboxes |
| Public edge | Keep API GW + WAF for browser/public; Lattice for east-west |
bash
# ✅ access log subscription on the service network
aws vpc-lattice put-access-log-subscription \
--resource-identifier sn-xxxx \
--destination-arn arn:aws:s3:::company-lattice-logs/coding-agent/
Production checklist
- [ ] Service network per environment (prod/sandbox); tagged
workload=coding-agent - [ ] Every tool registered as a Lattice service with
AWS_IAMauth - [ ] Auth policies least-privilege by planner/tool role ARNs
- [ ] Tenant id conditions aligned with session tags on AssumeRole
- [ ] Access logs retained ≥ 90 days; SIEM ingest
- [ ] No
auth-type NONEin prod - [ ] Cedar/Verified Permissions still authorize tool arguments
- [ ] Bedrock stays on PrivateLink — Lattice is for your services
- [ ] Chaos: revoke planner role → invokes must 403 (FIS post next)
FAQ
Q: Lattice vs PrivateLink?A: PrivateLink exposes a specific endpoint service (great for Bedrock or a single SaaS). Lattice is a many-service network with shared auth and discovery for internal microservices. Q: Does Lattice replace API Gateway?
A: No. API Gateway/WAF remains the north-south public/partner edge. Lattice is east-west inside AWS. Q: Lambda tools supported?
A: Yes — Lattice can target Lambda (and other target types). Still apply auth policies; do not rely on “Lambda URL open to VPC” shortcuts.
Migration path from SG spaghetti
Do not flip every tool on day one. Pick the hottest east-west path (usually planner → sandbox-exec). Register that service on Lattice, dual-run with the old SG path behind a flag, then remove the wide SG rule once SigV4 clients are stable. Next: RAG search. Last: anything that still needs raw IP allowlists for legacy agents.bash
Document the Lattice DNS names in your internal service catalog so agents (and humans) stop hardcoding private IPs that die on redeploy.
# ✅ verify auth: unsigned request must fail
curl -i "https://sandbox-exec-xxxx.vpc-lattice-svcs.us-east-1.on.aws/v1/exec" -H "content-type: application/json" -d '{"cmd":"true"}'
# expect 403 — ✅
# ❌ if 200, auth-type is wrong or policy is open
Related reading
- AWS PrivateLink for Bedrock: Keep Model Calls Off the Public Internet
- AWS Verified Permissions (Cedar): Authorize Agent Tools
- AWS Network Firewall: Egress Filtering for Coding-Agent Sandboxes
- AWS App Runner: Host Coding-Agent HTTP APIs
Watch: 100 Days of AI on YouTube
Short videos from CheatCoders, one AI engineering topic per day.
Most viewed
- Python Decorators Explained: From Simple Wrappers to Production Patterns
- AI Agent Frameworks in 2025: LangGraph vs CrewAI vs AutoGen vs Raw API
- Claude Code vs Cursor vs GitHub Copilot: Choose by Workflow, and Set Up One Repo That Works With All Three
- Python String Methods: Every str Method With Real Production Examples
- API Debugging in 30 Seconds: The Fastest Ways to Fix API Issues
Newly added
- n8n vs AI Agent: I Gave Both the Same Job (Local, Ollama)
- Local AI Video Generator: Build Your Own App (Free, Python, No GPU)
- AI Wrote Raw Binary Instead of Code. Here’s What Happened (WebAssembly)
- I Built a Browser That Only Runs Encrypted Binary (Ep 1)
- RAG From Scratch: Chunking, Embeddings, Reranking and Evaluation (Real Numbers)
Deep-dive PDF
Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.
Already subscribed? or open the subscribe page.
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.