This directory contains the Kong API Gateway configuration for AWS ECS deployment.
Kong acts as the single entry point for all BidderGod microservices, providing:
- API Routing: Routes requests to appropriate microservices
- CORS Handling: Configured for frontend access
- Rate Limiting: Protects services from overload
- Service Discovery: Uses AWS Cloud Map DNS (
.biddergod-dev.local)
Dockerfile- Builds custom Kong image with embedded configurationkong.yml- Declarative configuration for routes and plugins.github/workflows/kong-ecr.yml- GitHub Actions CI/CD pipeline
All services use private DNS resolution via AWS Cloud Map:
http://user-service.biddergod-dev.local:8080
http://auction-service.biddergod-dev.local:4000
http://bid-command.biddergod-dev.local:8080
http://bid-query.biddergod-dev.local:8080
http://payment-service.biddergod-dev.local:3000
http://sse-stream-service.biddergod-dev.local:8086| External Path | Method | Internal Service | Description |
|---|---|---|---|
/api/users |
ALL | user-service:8080 | User management |
/api/auctions |
ALL | auction-service:4000/auctions | Auction CRUD |
/api/auction-health |
GET | auction-service:4000/health | Health check |
/api/v1/bids |
POST | bid-command:8080 | Place bids (write) |
/api/v1/bids |
GET | bid-query:8080 | Query bids (read) |
/api/payments |
ALL | payment-service:3000 | Payment processing |
/events |
GET | sse-stream-service:8086 | Server-Sent Events |
CORS - All services:
- Origins:
*(all origins allowed) - Credentials: Enabled
- Max age: 3600s
Rate Limiting:
- User Service: 100 req/min
- Auction Service: 100 req/min
- Bid Command: 200 req/min
- Bid Query: 300 req/min
- Payment Service: 50 req/min
- SSE: No rate limiting (long-lived connections)
cd kong-gateway/
# Build locally (optional)
docker build -t kong-gateway .
# Deploy via GitHub Actions
git tag kong-1.0.0
git push origin kong-1.0.0# Check Kong service status
make get-service-ip-kong
# Test Kong health
KONG_IP=$(make -s get-service-ip-kong)
curl http://$KONG_IP:8000/status
# Test API routing
curl http://$KONG_IP:8000/api/users
curl http://$KONG_IP:8000/api/auctions# Get Kong IP
KONG_IP=$(make -s get-service-ip-kong)
# View all configured services
curl http://$KONG_IP:8001/services
# View all routes
curl http://$KONG_IP:8001/routes
# View plugins
curl http://$KONG_IP:8001/plugins- Edit
kong.ymlto add/modify routes - Commit changes
- Tag and push:
git tag kong-1.1.0 git push origin kong-1.1.0
- GitHub Actions will automatically build and deploy
services:
- name: my-service
url: http://my-service.biddergod-dev.local:8080
routes:
- name: my-route
paths:
- /api/my-path
strip_path: false # Keep /api/my-path in upstream request
plugins:
- name: cors
config:
origins: ["*"]
- name: rate-limiting
config:
minute: 100# Check logs
make logs-kong
# Common issues:
# 1. Invalid kong.yml syntax - validate YAML
# 2. Service discovery failing - check Cloud Map
# 3. Port conflicts - ensure port 8000/8001 are available# Verify Kong loaded configuration
KONG_IP=$(make -s get-service-ip-kong)
curl http://$KONG_IP:8001/routes | jq
# Check if services are reachable from Kong
# Services must be running and registered in Cloud Map
make cloud-map-servicesKong CORS plugin is configured for all origins (*). If you still get CORS errors:
- Check browser console for specific error
- Verify the route matches (check paths in
kong.yml) - Ensure OPTIONS requests are allowed
┌─────────────┐
│ Client │
└──────┬──────┘
│ HTTP
↓
┌─────────────────────────────────┐
│ Kong API Gateway (Port 8000) │
│ - Route matching │
│ - CORS handling │
│ - Rate limiting │
│ - Request/response transform │
└────────────┬────────────────────┘
│ AWS Cloud Map DNS
│ (.biddergod-dev.local)
↓
┌────────────────────────────────────┐
│ ECS Fargate Services │
│ ┌──────────────────────────────┐ │
│ │ user-service (8080) │ │
│ │ auction-service (4000) │ │
│ │ bid-command (8080) │ │
│ │ bid-query (8080) │ │
│ │ payment-service (3000) │ │
│ │ sse-stream-service (8086) │ │
│ └──────────────────────────────┘ │
└────────────────────────────────────┘
- Proxy:
http://<kong-ip>:8000- Main API gateway - Admin API:
http://<kong-ip>:8001- Configuration and monitoring - Health:
http://<kong-ip>:8000/status- Health check endpoint
- Monitor Kong: Set up Prometheus metrics export
- Authentication: Add JWT or OAuth2 plugin
- API Keys: Add key-auth plugin for service-to-service auth
- Request Logging: Enable file-log plugin for audit trails
- Custom Plugins: Develop custom plugins for business logic