Target Audience: Platform engineers, DevOps, SREs, and architects building public-facing APIs on AWS.
This guide outlines a pragmatic, production-ready pattern for exposing an internal backend running on Amazon EKS through a service mesh (Istio) and a hardened external proxy (HAProxy) managed via Terraform. We will cover architecture, traffic flow, security, observability, cost considerations, and deployment snippets.
1. Clients (public internet) → 2. Cloud Load Balancer / CDN (optional) → 3. External HAProxy (EC2/ASG) → 4. Ingress Gateway (Istio) on EKS → 5. Istio Mesh + App Pods → 6. Backends (DBs, caches, third-party APIs)
HAProxy provides a mature, low-latency L7 proxy with advanced ACLs, traffic shaping, header rewriting, and integration with existing datacenter tooling. Istio handles service-to-service security, retries, circuit breaking, and observability inside the cluster.
Terraform manages HAProxy infrastructure and cloud resources; GitOps (ArgoCD/Flux) manages Kubernetes manifests and Istio configuration.
Rate limiting & quotas: Implement at the edge (HAProxy) and again at mesh-level for defense-in-depth.
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: public-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts: ["api.example.com"]
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: istio-public-cert
hosts: ["api.example.com"]
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: api
spec:
hosts: ["api.example.com"]
gateways: ["public-gateway"]
http:
- match:
- uri:
prefix: "/v1"
route:
- destination:
host: api-service
port:
number: 80
resource "aws_launch_template" "haproxy" {
/* AMI with HAProxy baked */
}
resource "aws_autoscaling_group" "haproxy_asg" {
/* subnets, LT, min/max, target group */
}
resource "aws_lb_target_group" "haproxy_tg" {
/* health checks */
}
resource "aws_lb" "public" {
/* NLB or ALB in front */
}
Prometheus scraping Envoy/HAProxy metrics.
Jaeger or Tempo integrated via Istio.
Centralized logging to CloudWatch/ELK via Fluentd/Fluent Bit.
| Approach | Pros | Cons |
|---|---|---|
| HAProxy on EC2 | Full control, advanced features | EC2 cost + management overhead |
| Managed Alternatives | Reduced operational burden | ALB/WAF may lack HAProxy flexibility |
| Istio Mesh | Deep observability & security | Sidecar overhead (budget CPU/RAM) |
This pattern gives teams the ability to combine a hardened, featureful proxy with the rich in-cluster capabilities of a service mesh. It balances operational control and platform consistency while enabling advanced traffic management, security, and progressive deployments. Adapt the exact placement of TLS, WAF, and proxying to match organizational risk and operational maturity.