AWS Builder Center

A Smaller Bedrock Gateway, Part 1: Why and When to Put a Private Gateway in Front of Amazon Bedrock

When a private LiteLLM gateway in front of Amazon Bedrock is worth it, what the two stacks create, and how the private boundary works.

Series: A Smaller Bedrock Gateway (8 articles)

  1. 1
    A Smaller Bedrock Gateway, Part 1: Why and When to Put a Private Gateway in Front of Amazon Bedrock This article
Sr. Solutions Architect, AWS
Last updated: 2026-11-13 (Fri) 18:22 GST
Most teams I work with as a solutions architect start their generative AI work by calling Amazon Bedrock directly, and for most applications that is exactly the right call. Bedrock already offers  OpenAI-compatible endpoints , and  application inference profiles  give you cost attribution without running anything yourself. A self-hosted proxy adds an image, a database, a deployment pipeline, and one more thing to page someone about.
Some teams do outgrow direct access, though. A platform team wants to hand out keys that are not AWS credentials, finance wants a hard stop before a team overspends, or security wants one private place to audit every model call. In this series, I will show you how to build a small, private LiteLLM gateway in front of Bedrock that meets those three needs and nothing more. Everything runs in a dedicated VPC with no internet gateway, no NAT gateway, and no route to the internet, and every claim in the series was checked against a live deployment.
In this first part, I will explain when a gateway is worth it, what the two CloudFormation stacks create, and how the private boundary is enforced. The rest of the series then builds it one layer at a time.

When a gateway is worth it

I recommend this gateway only when at least one of these is a real requirement:
  1. Opaque virtual keys that are not AWS credentials. A platform team can mint and revoke a LiteLLM key without giving each client an AWS identity.
  1. Budget denial before the model call. LiteLLM compares a key's recorded spend plus the estimated cost of the incoming request with the key's budget, and rejects the request before it reaches Bedrock if the total would exceed it. The estimate comes from the request, so the final recorded cost can still differ slightly. Treat a budget as a strong spend control, not a guarantee to the cent.
  1. One private boundary to audit. Shared applications send traffic to one gateway whose routes, security groups, DNS policy, endpoint policies, and logs can be reviewed together.
If none of these apply, call Bedrock directly. If you need to reach model providers outside AWS, look at the  Guidance for Multi-Provider Generative AI Gateway on AWS  instead. Its  repository  documents an outbound-enabled design for public provider APIs. The templates in this series deliberately support Bedrock only and have no NAT mode.
The AWS multi-provider guidance in its default outbound-enabled mode, compared with the private boun

Figure 1. The AWS multi-provider guidance in its default outbound-enabled mode, compared with the private boundary in this series.

What you will build

The solution is two CloudFormation stacks. The network stack creates a dedicated VPC with two private subnets, route tables with no default route, a security-group graph, Route 53 Resolver DNS Firewall, a private hosted zone, VPC Flow Logs, an S3 bucket for load balancer access logs, five interface endpoints (Bedrock Runtime, ECR API, ECR Docker, Secrets Manager, and CloudWatch Logs), and an S3 gateway endpoint.
The gateway stack adds an internal HTTPS Application Load Balancer, Amazon ECS on AWS Fargate migration and runtime task definitions, a private Multi-AZ Amazon RDS for PostgreSQL database, a two-node Amazon ElastiCache for Valkey replication group, generated secrets, CloudWatch alarms, and an ECS service. The service starts with zero tasks. You raise it to two only after the database migration has finished successfully.
The private gateway network boundary and every dependency path the templates create.

Figure 2. The private gateway network boundary and every dependency path the templates create.

How a request flows

A client presents a virtual key to the internal load balancer. LiteLLM checks the key and its recorded spend in PostgreSQL, coordinates rate limits and budgets with the other replica through Valkey, and sends an admitted call to Bedrock Runtime over AWS PrivateLink. Container logs go to a CloudWatch Logs group. CloudTrail and Bedrock model invocation logging are account-level settings, so the stacks do not create them. Turn them on separately if you need them.
The request path the stacks deploy, and the account-level logging controls they do not.

Figure 3. The request path the stacks deploy, and the account-level logging controls they do not.

How the private boundary is enforced

No single control proves that the gateway is private, so the design layers several.
Routes. The templates create no internet gateway, NAT gateway, transit gateway, VPN, or Resolver inbound endpoint, and no IPv4 or IPv6 default route. Each private route table holds only the local route and the S3 gateway endpoint route.
Task egress. The task security group allows only TCP 443 to the endpoint security group, TCP 443 to the Regional S3 prefix list, TCP 5432 to the database security group, and TCP 6379 to the cache security group. This allowlist still holds if someone later edits a route table.
Endpoint policies. The Bedrock endpoint policy allows only the configured inference profile, model, actions, and same-account callers. The ECR, Secrets Manager, and Logs endpoint policies are scoped by service, action, and account, and the task roles add the exact repository, secret, and log-group restrictions.
DNS Firewall. An allow rule covers the required AWS and private-zone names, and a final rule blocks every other name with NXDOMAIN. The allow rule trusts redirections because Amazon S3 answers the ECR layer bucket name with a CNAME to a Regional S3 name. Fail-open is a VPC-level setting whose default is disabled. The templates do not own it, so Part 3 shows you how to confirm it before you deploy the gateway.
Image pulls. Fargate pulls image layers from S3 through the gateway endpoint, which is why the task security group needs the S3 prefix-list rule.
TLS. Clients connect to the internal load balancer over TLS 1.2 or 1.3. The hop from the load balancer to the task is HTTP on port 4000 inside the security-group boundary. If your policy requires encryption on that hop, this template does not meet it yet. PostgreSQL connections use TLS with full certificate verification, and Valkey requires TLS and a deployment-unique user.
The AWS Europe geography. The source Region is Frankfurt ( eu-central-1 ) and the model is the  eu.anthropic.claude-sonnet-4-6  geographic inference profile. The Bedrock endpoint policy and the runtime role both list the same six destination Regions of the  AWS Europe geography : Frankfurt, Stockholm, Milan, Spain, Ireland, and Paris. Check  model availability by Region  before each deployment, and update both lists together if AWS changes the set.

Two replicas, one source of truth

The service runs two replicas. Rate limits and budgets are per-key state, so the replicas share it through Valkey instead of keeping private counters. Response caching is off. The gateway fails closed: if Valkey is unavailable, requests are denied rather than silently admitted. A revoked key can stay valid for up to five seconds on a replica that had already cached it.

What you need to provide

An internal load balancer is private, but it does not make your corporate network able to reach it. You provide the Transit Gateway, VPN, or Direct Connect path, the return routes, DNS forwarding to the private hosted zone, and a certificate your clients trust. You also choose two non-overlapping private ranges: one for clients, which can reach chat and health paths, and one for administrators, which can also reach the key-management paths.

Prerequisites

To follow along, you need:
  • An AWS account you can use for testing, and the AWS CLI configured with permissions to create the resources above. Use the  eu-central-1  (Frankfurt) Region; both templates refuse any other.
  • Access to the  eu.anthropic.claude-sonnet-4-6  inference profile in Amazon Bedrock for that account.
  • An Amazon ECR repository in the same account and Region for the gateway image.
  • An AWS Certificate Manager certificate in  eu-central-1  that covers the gateway's private host name, for example  litellm.internal.example .
  • An S3 bucket you own for staging the gateway template. At about 76 KB, it is larger than the 51,200-byte limit for inline templates.
  • A shell with  awk  and  shasum , which you use to rejoin each template from the blocks in Parts 2, 3, 5, 6, and 7.

How the rest of the series is organized

Each of the following parts covers one layer. It explains what the layer does and why, shows that layer's part of the template in full as readable YAML, and ends with the hands-on step that deploys or checks it.
  • Part 2 covers the network boundary: the isolated VPC, flow logs, DNS Firewall, the private hosted zone, and the log bucket.
  • Part 3 covers the security groups and private endpoints, then deploys the network stack and checks the boundary in the console.
  • Part 4 builds the hardened LiteLLM image and checks its scan.
  • Parts 5, 6, and 7 cover the gateway stack: inputs, secrets, and the data tier; the load balancer and IAM roles; and the tasks, service, and alarms.
  • Part 8 deploys the gateway, runs the migration gate, sends the first request, and covers validation and day-two operations.

Conclusion

A gateway is worth running when you need non-AWS virtual keys, spend limits enforced before the model call, or one private boundary to audit. In this part, I covered what the stacks build and how each layer keeps traffic private. In Part 2, I will start building the network boundary.
This is Part 1 of the eight-part A Smaller Bedrock Gateway series. Part 1 covers the design, Parts 2 and 3 the network stack, Part 4 the hardened image, Parts 5 to 7 the gateway stack, and Part 8 the deployment, validation, and day-two operations.

Series: A Smaller Bedrock Gateway (8 articles)

  1. 1
    A Smaller Bedrock Gateway, Part 1: Why and When to Put a Private Gateway in Front of Amazon Bedrock This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article