Skip to content

AWS deployment reference

Template: deploy/aws/gateway-fargate-marketplace.yaml. For the buyer walkthrough see buyer getting started.

What the stack creates

Resource Purpose
Application Load Balancer, HTTPS 443 Gateway endpoint. TLS 1.3/1.2 policy, idle timeout 300 s for long streams
Listener rule /admin* + source IP Cognito or OIDC sign-in at the ALB, only from AdminAllowedCidr; other sources get 403 at the edge
Default listener action Forward without sign-in: API clients authenticate with gateway keys
ECS Fargate service (MinTasks–MaxTasks) Task = migrate init container (Create mode) + gateway (:8080, /healthz; metrics :9090 not exposed) + presidio analyzer (:3000, task-local)
CPU target-tracking autoscaling Holds ScaleCpuTarget percent average CPU
RDS PostgreSQL (optional) Encrypted, private, RDS-managed master secret; audit log, license lease state, shared rate-limit windows
Secret gateway_app (Create mode) Generated password of the least-privilege runtime database role
SSM parameter /<stack>/gateway-config Gateway config JSON, no secrets. Read at start and on every reload (GATEWAY_CONFIG_SSM_PARAMETER)
Task role bedrock:InvokeModel* on BedrockModelArns when EnableBedrock=true; nothing else
Execution role Reads only the enrollment secret, DB secrets, provider key secrets and the config parameter
Interface VPC endpoint (optional) bedrock-runtime in the task subnets
Cognito user pool (AuthMode=Cognito) Admin sign-in; custom:gateway_role=admin

Data boundary

  • Prompts and completions flow application → ALB → gateway task → model provider. The gateway rewrites them before they leave the task.
  • To Software Sushi's control plane: deployment metadata and signed lease renewals only (deployment_id, app_version, last_revision, optional hourly request counts). No prompt text, entity values, audit rows, keys or operator identities.
  • The analyzer port and metrics port are not reachable from the load balancer.

Container environment contract

Variable Source Meaning
GATEWAY_CONFIG_SSM_PARAMETER Template (parameter name) Config is fetched with ssm:GetParameter at start and on reload (SIGHUP or admin console); takes precedence over GATEWAY_CONFIG_JSON and GATEWAY_CONFIG
OPENAI_API_KEY, ANTHROPIC_API_KEY Buyer secrets (optional) Referenced by api_key_env in the config
AWS_REGION Stack region Bedrock upstream region and SDK default
GATEWAY_DB_HOST/PORT/NAME/USER/PASSWORD RDS endpoint + gateway_app secret DatabaseMode=Create; TLS (sslmode=require) is enforced by the binary
GATEWAY_DB_MIGRATE=false constant (Create mode) Do not migrate; fail fast if the schema is older than the binary
GATEWAY_DATABASE_URL Buyer secret DatabaseMode=Existing
GATEWAY_ADMIN_OIDC=alb constant Trust /admin identity only from ALB-signed x-amzn-oidc-data
GATEWAY_ADMIN_ALB_ARN the stack's ALB Expected signer of that token
GATEWAY_ADMIN_ROLE_CLAIM, GATEWAY_ADMIN_VALUES custom:gateway_role/admin or OIDC params Admin authorization
GATEWAY_LICENSE_* Template parameters ENFORCED, CONTROL_PLANE_URL, ALLOWED_HOSTS, PUBLIC_KEYS_JSON, ENROLLMENT_TOKEN, AWS_ACCOUNT_ID, STACK_ID, REGION, ENVIRONMENT, RENEW_INTERVAL; STATE_FILE unset = lease state in PostgreSQL

Database roles

In DatabaseMode=Create the gateway container never receives the RDS master secret. Each task starts a short-lived migrate container first (same image, gateway migrate) that connects as the master user, applies migrations under an advisory lock and creates or updates the gateway_app role. The gateway container starts only after it exits successfully and connects as gateway_app, which can:

Table Privileges
gateway_audit_events SELECT, INSERT (append-only: no update, delete or truncate)
gateway_license_state SELECT, INSERT, UPDATE
gateway_rate_windows SELECT, INSERT, UPDATE, DELETE
gateway_schema_migrations SELECT

It cannot create or alter objects. Audit retention runs through the owner-privileged gateway_purge_audit function, which never deletes events younger than the stack's AuditRetentionDays (0 disables purging). A retention_days in the gateway config can lengthen retention but not shorten it below that floor; change the stack parameter to shorten it.

The role password is stored as a SCRAM verifier, never in clear text. To rotate it, put a new value in the gateway_app secret and force a new deployment; new tasks re-provision the role before starting. Tasks still on the old password keep their open connections until they are replaced.

In DatabaseMode=Existing the gateway migrates with the role in DatabaseUrlSecretArn, which must own the schema. To run it least-privilege there too, run gateway migrate once as the owner with GATEWAY_DB_APP_USER/GATEWAY_DB_APP_PASSWORD (and optionally GATEWAY_AUDIT_MIN_RETENTION_DAYS), point the secret at that role, and set GATEWAY_DB_MIGRATE=false. Repeat gateway migrate before each upgrade.

Changing configuration

Edit the SSM parameter (for example to add keys or policies), then open the admin console, System > Reload configuration. Each running task re-reads the parameter; an invalid document is rejected and the previous configuration stays active. Reload applies per task, so with several tasks either reload until every task reports the new configuration or roll the service: aws ecs update-service --cluster <stack> --service <stack>-gateway --force-new-deployment. Listen addresses and enabling Bedrock need a new deployment. A later stack update rewrites the parameter from template values, so keep durable changes in your own copy of the config or apply them again after updates.

Networking variants

  • Public subnets, no NAT: AssignPublicIp=ENABLED.
  • Private subnets with NAT: AssignPublicIp=DISABLED, TaskSubnetIds = private subnets.
  • Private subnets without internet: additionally needs VPC endpoints for ECR (api, dkr), S3 gateway, Secrets Manager, SSM, CloudWatch Logs and CreateBedrockVpcEndpoint=true; OpenAI/Anthropic and the license control plane still need an egress path (NAT or proxy).

Operating notes

  • Autoscaling: per-key rpm/tpm limits are shared by all tasks through the audit database, so scaling out does not raise a key's limit. During a database outage each task enforces the full limit on its own (gateway_rate_limit_fallback_total increases).
  • Deleting the stack snapshots the database (DeletionPolicy: Snapshot).
  • Upgrades: Quick Launch a new template version or update the stack with new image digests; rolling deployment keeps 100% healthy capacity.

Last updated November 29, 2026 · Suggest an improvement