Skip to main content
This page walks through one way to run Claude apps gateway on AWS. The configuration is a working example for customer-managed infrastructure rather than a supported production deployment; use it to see how the pieces fit together before adapting it to your own environment. For the platform-agnostic requirements, see the deployment guide.
This example provisions Claude apps gateway on AWS with Amazon Bedrock as the model upstream, using either Amazon ECS on AWS Fargate or Amazon EKS for compute. Okta is the example identity provider (IdP), but any OpenID Connect (OIDC) compliant IdP works; see Identity provider setup for per-IdP details.
Bedrock isn’t the only Claude upstream on AWS. The gateway also supports Claude Platform on AWS, the Anthropic-operated Claude API with AWS authentication and AWS Marketplace billing, in place of Bedrock or alongside it. Its upstream entry, credentials, and IAM permissions differ from this page’s Bedrock-scoped ones; the Claude Platform on AWS upstream reference covers what changes, and the rest of this page applies unchanged.

Architecture

Diagram of Claude apps gateway on AWS: Claude Code clients connect over HTTPS to an internal Application Load Balancer fronting the gateway (ECS Fargate or EKS), which runs in private subnets alongside an Amazon RDS for PostgreSQL instance for session state. The gateway signs users in via OIDC against the corporate IdP, reads secrets from AWS Secrets Manager, forwards model requests to Amazon Bedrock using its IAM role, and pulls its image from Amazon ECR at deploy.

The example architecture, with Amazon Bedrock as the model upstream. A Claude Platform on AWS upstream occupies the same position.

The gateway runs as a private HTTPS endpoint on your network that developers sign in to through your IdP. Their Claude Code sessions reach Claude models on Amazon Bedrock through the gateway’s IAM role, so no model credentials land on developer machines. The reference configuration provisions:
  • Amazon ECS on AWS Fargate service or Amazon EKS Deployment running the gateway container
  • Amazon ECR repository for the gateway image
  • Amazon RDS for PostgreSQL instance in private subnets, not publicly accessible, for the gateway’s store
  • AWS Secrets Manager secrets for the JWT signing key, the OIDC client secret, and the Postgres URL
  • IAM role with bedrock:InvokeModel and bedrock:InvokeModelWithResponseStream, attached as the ECS task role or bound via IAM Roles for Service Accounts (IRSA) on EKS
  • Internal Application Load Balancer for HTTPS

Prerequisites

The walkthrough creates the gateway’s own resources, but it builds on network and identity infrastructure you already have. Before you start, you need:

Set your environment variables

Every command on this page reads four values from your shell: AWS_REGION, ACCOUNT_ID, VPC_ID, and PRIVATE_SUBNETS. Pick a US region where Bedrock serves the Claude models you need. The walkthrough relies on the gateway’s built-in model catalog, which resolves to us.anthropic.* inference profiles, and the IAM policy grants those ARNs. In a non-US region, add a models: block with that geo’s inference-profile IDs and change the IAM policy’s ARN prefix to match. If you don’t have the VPC ID at hand, list your VPCs with aws ec2 describe-vpcs, then list that VPC’s subnets to find two private ones in different Availability Zones:
Export all four before continuing:

Deploy the gateway

The steps below provision the full deployment with aws commands.
1

Create the security groups

Three security groups chain the traffic path: your corporate network reaches the load balancer on 443, the load balancer reaches the gateway on 8080, and the gateway reaches Postgres on 5432. Nothing else is reachable. How you attach them depends on the compute track:
  • On ECS Fargate, the deploy step attaches $ALB_SG to the load balancer and $GW_SG to the service.
  • On EKS, the AWS Load Balancer Controller creates its own frontend security group for the ALB, so $ALB_SG and $GW_SG go unused: the deploy step’s inbound-cidrs annotation restricts the listener to your corporate network, and the database security group admits the cluster’s security group instead.
2

Create the IAM roles and submit the use case form

The gateway runs with a dedicated task role whose only permission is invoking Claude models on Bedrock. Per the Bedrock upstream reference, the policy must cover both the cross-region inference-profile ARNs and the underlying foundation-model ARNs:
ECS also needs an execution role, which the ECS agent itself uses to pull the image from ECR and inject the Secrets Manager values created later. It is separate from the task role the gateway’s AWS SDK uses at runtime:
The policy names one ARN per secret rather than a bare gateway-* wildcard, which in a shared account would also match unrelated secrets; the trailing -?????? matches exactly the random six-character suffix Secrets Manager appends to every secret’s ARN. A trailing -* would be a plain prefix glob and would also match longer names such as gateway-postgres-url-prod.The IAM policy grants the gateway permission to call Bedrock, and Bedrock enables model access by default in commercial regions. The remaining account-level gate is Anthropic’s one-time use case form: if no one in your account has submitted it, open the Amazon Bedrock console, select an Anthropic model from the Model catalog, and complete the form. Access is granted immediately after submission; see Claude Code on Amazon Bedrock for the AWS Organizations form and the IAM permissions the submitter needs.The EKS track reuses both policy documents on an IRSA role instead of the two ECS roles; see the deploy step.
3

Provision Amazon RDS for PostgreSQL

The instance runs in the private subnets with no public address and storage encryption on. The engine version is pinned to Postgres 16, which satisfies the gateway’s supported floor of PostgreSQL 14 and guarantees the parameter-group family below matches the instance.First, create the subnet group that places the database in the private subnets, and a parameter group with rds.force_ssl=1 so the server rejects plaintext connections. The engine version is pinned once because the parameter group’s family must match the engine major version the instance runs:
Then create the instance with a generated master password:
The literal --master-user-password argument is visible in the process table and in audit/EDR logs while the command runs, the same exposure the secrets step’s note covers. On a shared or monitored host, pass the password via --cli-input-json from a 0600 file instead, the way the bundle’s setup.sh does.Wait for the instance to come up, which can take several minutes, then read its private endpoint and assemble the connection string the gateway will use:
sslmode=verify-full makes the gateway verify the RDS server certificate’s chain and hostname, not only encrypt. The trust anchor is the AWS RDS certificate bundle, which the image build step below copies to /etc/claude/rds-global-bundle.pem and trusts via NODE_EXTRA_CA_CERTS. Don’t append a libpq-style sslrootcert= parameter to the URL: the gateway’s driver reads only sslmode from the query string and would forward sslrootcert to Postgres as a startup parameter, which the server rejects.The ECS service or EKS pods must run in this VPC so they can reach the instance’s private endpoint, and the claude-gateway-db security group only admits the gateway’s security group.
4

Write gateway.yaml

The upstreams block points at Bedrock with auth: {}, so the gateway authenticates via the AWS default credential chain from the task role on ECS or the IRSA role on EKS. See the configuration reference for every field.Two listen fields depend on what fronts the gateway:
  • public_url: required behind a load balancer. The gateway builds the IdP redirect_uri and its discovery document only from this value, never from X-Forwarded-* headers.
  • trusted_proxies: the front end’s source ranges. The gateway honors X-Forwarded-For only when the TCP peer is in this list, then walks the chain past trusted hops, so per-IP sign-in rate limits and audit events record developer IPs instead of the load balancer’s.
On both tracks the front end is an internal ALB, whether created directly or by the AWS Load Balancer Controller, and an ALB’s nodes take addresses from the subnets it is attached to, so set trusted_proxies to those subnets’ CIDRs. This trusts every host in those subnets as a proxy. Keep the ALB’s ingress source, your corporate CIDR, from overlapping them, and don’t share the subnets with untrusted workloads that could spoof client IPs via X-Forwarded-For.
gateway.yaml
Only the oidc block is Okta-specific. To use Microsoft Entra ID instead, set issuer to https://login.microsoftonline.com/<tenant-id>/v2.0, drop userinfo_fallback and the groups scope, and note that Entra emits group Object IDs rather than names, so managed.policies must match on the GUIDs, or on App Roles with oidc.groups_claim: roles. See Identity provider setup.
5

Store secrets in AWS Secrets Manager

Create three secrets; the execution role from the IAM step can already read them:
Note the ARN each call prints; the ECS task definition references secrets by ARN.
Literal --secret-string arguments are visible in the process table and in audit/EDR logs while each command runs. On a shared or monitored host, put the value in a 0600 file and pass --secret-string file://<path> instead. The bundle’s setup.sh keeps secret values off process argv the same way, passing 0600 temporary files to --cli-input-json.
Unlike the secrets, gateway.yaml itself contains no secret values, because every credential resolves at boot through ${VAR} or ${file:...} expansion. How everything reaches the container differs by track:
  • On ECS, the next step’s build copies gateway.yaml into the image at /etc/claude/gateway.yaml, and the task definition injects the three secrets as environment variables via its secrets field, so the YAML references ${GATEWAY_JWT_SECRET}, ${OIDC_CLIENT_SECRET}, and ${GATEWAY_POSTGRES_URL}.
  • On EKS, mount gateway.yaml from a ConfigMap and the secrets as files at /secrets, referenced as ${file:/secrets/...}. Source the Kubernetes Secrets from Secrets Manager with External Secrets Operator or the Secrets Store CSI driver’s AWS provider, or create them directly with kubectl.
6

Build and push the image to Amazon ECR

Build the image per the container image requirements, placing the linux-x64 glibc binary at ./claude in the build context. Write your own Dockerfile per those requirements or start from the bundle’s Dockerfile, which copies the filled-in gateway.yaml from the previous steps into the image at /etc/claude/gateway.yaml. On ECS that embedded copy is how the configuration reaches the container, which is why the build comes after the file is written. The EKS track instead mounts gateway.yaml from a ConfigMap at deploy, so the embedded copy is unused there.The image also carries the AWS RDS certificate bundle as the trust anchor for the connection string’s sslmode=verify-full, so download it into the build context first. AWS rotates the bundle (new regional CAs get appended), so download it per build rather than pinning a checksum or committing it:
The container image requirements don’t cover the bundle, so if you write your own Dockerfile, add the two lines that copy and trust it; the bundle’s Dockerfile already includes both:
Create the ECR repository and sign Docker in to it. Immutable tags mean the <version> tag the deploy step pins cannot later be silently re-pointed at a different image:
Build and push the image. The task definition below runs linux/amd64, so the platform must match here; for Fargate on ARM64 (Graviton), build linux/arm64 with the linux-arm64 binary and set cpuArchitecture to ARM64 instead:
7

Deploy

Create the cluster and a log group for the gateway’s stderr, which carries both its audit events and operational logs. Retention is a separate call, and without one CloudWatch keeps the logs forever; align the 90 days with your audit retention policy:
Write the task definition. The task role carries the Bedrock permission and the execution role injects the secrets; use the secret ARNs from the Secrets Manager step:
claude-gateway-task.json
Register it:
Put an internal ALB in front with a target group that health-checks the gateway. --ip-address-type ipv4 matters: an internal dual-stack ALB publishes public-range AAAA records, which the /login private-network check rejects:
Add the HTTPS listener and raise the idle timeout. --ssl-policy pins a modern TLS floor, since omitting it falls back to the legacy ELBSecurityPolicy-2016-08 default, which still accepts TLS 1.0/1.1. The idle timeout matters for streaming: the ALB closes a connection after 60 seconds with no data by default, which cuts off streams during quiet periods, such as long prompt processing before the first token:
Create the service. The deployment circuit breaker rolls a deployment whose tasks keep failing, from a bad image or an unbootable config, back to the last steady state instead of relaunching failing tasks forever:
The 60-second grace period gives a cold task time to pull the image, connect to the store, and answer its first health check before ECS starts counting failures against the deployment. The target group’s health check on GET /readyz verifies the store is reachable, so a task that can’t reach Postgres never enters rotation; see Outage behavior for the tradeoff and the /healthz alternative.The tasks run in private subnets with no public IP, so all egress (to Bedrock, your IdP, Secrets Manager, ECR, and CloudWatch Logs) goes through the NAT gateway. To keep Bedrock traffic off the public path, create a bedrock-runtime interface VPC endpoint and point the upstream’s base_url at it, as shown in the Bedrock upstream reference; the IdP still needs internet egress.Finish by giving developers a privately resolvable hostname: in a Route 53 private hosted zone, alias the gateway’s internal DNS name to the ALB, and set listen.public_url to that hostname. The ALB’s own *.elb.amazonaws.com name resolves to private addresses on an internal ALB, but it can’t carry your ACM certificate, so use your own name.Update the OAuth client’s authorized redirect URI to <public_url>/oauth/callback before the first sign-in. After changing public_url, rebuild and push the image under a new tag, register a new task definition revision, and redeploy. On ECS the setting lives in the image’s embedded gateway.yaml, and the gateway builds its public origin only from that setting, ignoring X-Forwarded-Host and X-Forwarded-Proto. X-Forwarded-For is honored for client IPs only when listen.trusted_proxies is set.
8

Push the gateway URL to developer machines

The gateway is now running, but developers can’t reach it from /login until the gateway URL is on their machines. Set forceLoginMethod and forceLoginGatewayUrl in the managed settings file you deploy to each device via MDM. There is no gateway option in the login picker for a developer to select manually.

Terraform reference

The companion bundle at examples/gateway/aws packages this page as code:
  • setup.sh scripts the provisioning walkthrough above with the same aws commands, on the ECS Fargate track. It is idempotent: existing resources are detected and skipped, so re-running it is safe, and any default can be overridden via environment variable. You still create the Okta OIDC client secret and the ACM certificate yourself: a run without them skips the ECS/ALB deploy, names the missing inputs, and prints the create-secret command; create both and re-run. The Bedrock use case form and the Route 53 alias print as next steps rather than running automatically, and the client MDM push stays a manual step from this page.
  • gateway.yaml.example is the configuration template from the gateway.yaml step, with the optional keys included commented out. Copy it to gateway.yaml and replace every REPLACE_ME before building.
  • Dockerfile builds the runtime image from the prebuilt linux-x64 binary and copies in your filled-in gateway.yaml at /etc/claude/gateway.yaml, plus the AWS RDS certificate bundle that anchors the store’s sslmode=verify-full. setup.sh downloads the bundle only when it isn’t already in the build context; delete the file and rebuild under a new tag to pick up an AWS CA rotation. The config file holds no secret values, since every credential resolves at boot through ${VAR} expansion. A config edit therefore means a rebuild under a new tag; setup.sh automates this by tagging images with a hash of the file.
  • terraform/ provisions the same ECS Fargate scope declaratively: the security groups, IAM roles, ECR repository, RDS instance, Secrets Manager secrets, and the ECS service behind the internal ALB. The VPC and private subnets stay prerequisites, passed in as variables. Terraform creates the ECR repository but doesn’t build the image, and the service definition references the image, so the apply is two passes: a targeted apply for the repository, then the build and push, then the full apply. The bundle’s terraform/README.md covers the variables, remote state, and teardown.
Like this page, the bundle is a working example for customer-managed infrastructure rather than a supported production deployment; review and adapt it to your own environment before relying on it.

Troubleshooting

For gateway boot and login errors, see the platform-agnostic troubleshooting table. The entries below are specific to AWS.

Telemetry

The gateway gives you per-developer usage metrics without any per-machine OTEL configuration. Claude Code emits OpenTelemetry (OTLP) metrics, logs, and opt-in traces; Monitoring usage covers everything the CLI reports. On gateway sessions the CLI stamps each export with the authenticated IdP identity attributes user.id, user.email, and user.groups, so usage rolls up per developer with no OTEL_RESOURCE_ATTRIBUTES plumbing. The gateway itself is an authenticated OTLP relay. Set telemetry.forward_to together with listen.public_url, and it pushes the OTEL exporter settings to every connected client and forwards their OTLP traffic verbatim to each destination you list. Each destination opts into metrics, logs, and traces independently, and the default is metrics only; see the telemetry reference for the per-signal fields and their sensitivity tradeoffs. The gateway doesn’t buffer, aggregate, or store telemetry, so where the data lands is entirely the collector’s exporter configuration. Client telemetry is off by default; configuring telemetry.forward_to is what turns it on for connected developers, and each interactive client shows a one-time security approval dialog for the pushed settings, as described in the configuration reference. On AWS, each signal maps to a destination as follows.

Client metrics, logs, and traces

Point telemetry.forward_to at an OpenTelemetry collector, such as the AWS Distro for OpenTelemetry (ADOT) collector, and export from there to Amazon CloudWatch, Amazon Managed Service for Prometheus, or any OTLP backend. Run the collector as its own internal service reachable over https://: the gateway accepts plaintext http:// only for loopback URLs, and even then its SSRF guard blocks loopback connections at send time by default. A sidecar collector on http://localhost:4318 passes config validation but receives no traffic, with exports failing as ECONNREFUSED_SSRF in the gateway logs, unless CLAUDE_GATEWAY_ALLOW_LOOPBACK=1 is set in the gateway’s environment. That variable relaxes the loopback block for every operator-configured URL, not only telemetry, so prefer the internal-service pattern and reserve the sidecar-plus-flag setup for tasks whose network is otherwise locked down.

Gateway logs

On ECS Fargate, no extra setup: the awslogs driver delivers the gateway’s stderr, which carries its audit events and operational logs, to the /ecs/claude-gateway log group created above. On EKS, pod logs don’t reach CloudWatch by default, so the audit trail is lost until you install log collection: the Amazon CloudWatch Observability add-on with container log capture enabled, or a Fluent Bit DaemonSet. On either track, query the logs with CloudWatch Logs Insights and drive alarms from metric filters.

Container metrics

Enable Container Insights on the cluster with aws ecs update-cluster-settings --cluster claude-gateway --settings name=containerInsights,value=enabled for per-task CPU, memory, and network. On EKS, install the Amazon CloudWatch Observability add-on.

Spend

Telemetry shows usage after the fact; spend limits are the gateway’s live per-developer view and enforcement on top of the shared upstream credential.

Next steps