Skip to content

AWS

This page describes the two artefacts shipped for an installation in your own AWS account: a Terraform profile in deploy/aws/ for the data services, identities and secrets, and a Helm chart in deploy/helm/spongram/ for the workloads on an existing EKS cluster. It runs the server with the Cloud control plane enabled. The component diagram is in Architecture on AWS.

Reference architecture, validated offline

These artefacts are a reference architecture. They are validated offline only (terraform validate, helm lint, helm template); the vendor has not performed an AWS deployment with them. The profile runs one API replica and single-instance Neo4j and Graphiti StatefulSets. It is not a high-availability qualification, and it carries no measured throughput, RPO or RTO. Qualify secret rotation, RDS TLS, IAM, snapshot restore, ingress streaming and your inference gateway in your own account before production use.

What you provide and what each artefact creates

You provide Terraform creates (deploy/aws/) Helm deploys (deploy/helm/spongram/)
VPC and at least two private subnets in different availability zones KMS key and alias for data encryption API Deployment, Service, ServiceAccount, PodDisruptionBudget
EKS cluster (Kubernetes 1.30 or later) with its IAM OIDC provider RDS PostgreSQL 17, Multi-AZ, private Graphiti StatefulSet and Service
Security group of the workload nodes or pods Security group for the data services Neo4j StatefulSet and Service (optional)
Ingress controller, DNS name, TLS certificate Two private S3 buckets (objects, backups) Migration Job (Helm hook, optional)
Encrypted EBS CSI StorageClass Secrets Manager secrets, created empty NetworkPolicy and Ingress (optional)
Kubernetes Secrets holding the runtime values IAM roles for the application, the migration job and a backup job
The two container images in your registry CloudWatch log group

Terraform does not create the cluster, the ingress controller, any Kubernetes object, or the agent that ships pod logs to CloudWatch. The chart does not create Kubernetes Secrets or a backup job.

The Terraform profile

Requires Terraform 1.5.7 or later (below 2.0) and the AWS provider ~> 6.0. Copy customer.tfvars.example and fill it in.

Inputs

Variable Default Meaning
name required Prefix of every resource name
region required AWS region
vpc_id required Existing VPC
private_subnet_ids required At least two private subnets
workload_security_group_id required Security group allowed to reach PostgreSQL on 5432
eks_oidc_provider_arn required ARN of the cluster's IAM OIDC provider
eks_oidc_issuer_host required OIDC issuer without https://
namespace spongram Kubernetes namespace bound in the role trust policies
postgres_version required Exact PostgreSQL 17 minor version available in the region; must start with 17.
database_instance_class db.r7g.large RDS instance class
database_allocated_storage 100 Initial storage in GB
database_max_allocated_storage 1000 Storage autoscaling ceiling in GB
objects_bucket_name, backups_bucket_name required Globally unique bucket names
backup_retention_days 35 Expiry of objects under snapshots/ in the backups bucket
rds_runtime_user spongram_app Database user the application may connect as with IAM authentication
self_hosted_langfuse false Create the cache, secret and role for a Langfuse server you host yourself
valkey_version, cache_node_type, cache_auth_token 8.2, cache.r7g.large, none Only used when self_hosted_langfuse = true; the token is then mandatory (32 to 128 characters)

Resources

Resource Configuration
KMS key alias/<name>-data Key rotation on, 30-day deletion window. Encrypts RDS, the S3 buckets and the secrets
RDS instance <name>-postgres Database spongram, gp3 encrypted storage, Multi-AZ, not publicly accessible, IAM database authentication enabled, master password managed in Secrets Manager, 35 days of automated backups, deletion protection, final snapshot, no automatic minor upgrade, PostgreSQL and upgrade logs exported to CloudWatch
DB parameter group rds.force_ssl = 1: the server refuses non-TLS connections
Security group <name>-data-… Ingress 5432 from workload_security_group_id only
S3 buckets Public access blocked, bucket-owner-enforced ownership, versioning, SSE-KMS with the key above, policy denying non-TLS requests. In the backups bucket, snapshots/ expires after backup_retention_days; journal/ is kept
Secrets Manager <name>/runtime, <name>/migration-db, <name>/runtime-db, <name>/neo4j, created without values, 30-day recovery window
IAM role <name>-application Assumable by service account spongram in namespace
IAM role <name>-migration Assumable by service account spongram-migration
IAM role <name>-backup Assumable by service account spongram-backup
CloudWatch log group /spongram/<name> 90 days retention

The RDS instance and both buckets carry prevent_destroy.

Outputs: postgres_endpoint, database_resource_id, objects_bucket, backups_bucket, kms_key_arn, application_role_arn, operator_role_arns, secret_arns, cloudwatch_log_group, and cache_endpoint (null unless Langfuse is self-hosted).

Store the Terraform state in an encrypted backend with restricted access.

Identities and secrets

No static AWS credential is used. Each pod assumes a role through its Kubernetes service account (IAM roles for service accounts).

Role May do May not do
Application Read the runtime-db secret; use the KMS key; read, write and delete objects under orgs/ in the objects bucket; rds-db:connect as rds_runtime_user Read the migration secret or the RDS master secret
Migration Read the migration-db secret; decrypt with the KMS key Anything else
Backup Read, write and list the backups bucket, including object versions; use the KMS key Read any database secret

The split has a database counterpart. The migration role connects as the schema owner and runs DDL. The application connects as a separate role that owns no table and is NOSUPERUSER NOBYPASSRLS. This is enforced twice: the migration command refuses to run if the runtime role is missing, is a superuser, has BYPASSRLS, or is the role it is connected as; and with SPONGRAM_CLOUD_CUSTOMER_INSTALLATION=true the API refuses to start if its own role is a superuser, has BYPASSRLS or owns tables.

Create the roles and schema before the first migration, with passwords supplied from your secret manager:

CREATE ROLE spongram_migrator LOGIN NOSUPERUSER NOBYPASSRLS;
CREATE ROLE spongram_app LOGIN NOSUPERUSER NOBYPASSRLS;
CREATE SCHEMA spongram AUTHORIZATION spongram_migrator;
ALTER ROLE spongram_migrator IN DATABASE spongram SET search_path = spongram;
ALTER ROLE spongram_app IN DATABASE spongram SET search_path = spongram;

Database secrets and aws-secretsmanager://

SPONGRAM_DATABASE_URL and SPONGRAM_MIGRATION_DATABASE_URL accept either a postgresql:// DSN or a reference of the form aws-secretsmanager://<secret-id>. With a reference, the process reads the secret through the standard AWS credential chain. The secret must be a JSON object:

{"host": "<rds-endpoint>", "port": 5432, "dbname": "spongram", "username": "spongram_app", "password": "<password>"}

The secret is read again for every new connection, so a password rotation that keeps the same host, user and database is picked up without a restart. A change of host, user or database is refused on the existing pool; restart the pods.

api.databaseAuth selects how the password is obtained:

Value Behaviour
secret (default) The password field of the secret
iam An RDS IAM authentication token generated for the username of the secret. Grant rds_iam to that database role; the application role already holds rds-db:connect for rds_runtime_user

RDS TLS

Connections made through a secret reference always use TLS 1.2 or later and verify both the certificate chain and the host name. The CA bundle is read from SPONGRAM_AWS_RDS_CA_BUNDLE, which the chart sets to /etc/rds-ca/global-bundle.pem. Create a ConfigMap named by api.rdsCaConfigMap (default spongram-rds-ca) with the AWS RDS CA bundle under the key global-bundle.pem.

Kubernetes Secrets

The chart loads three Secrets with envFrom. Create them in the namespace, from your secret manager, before installing. The chart sets no value for the following variables, so the Secrets must supply them:

Secret (value key) Variables it must provide
api.runtimeSecret (spongram-runtime) SPONGRAM_ADMIN_TOKEN, SPONGRAM_ENCRYPTION_KEY, SPONGRAM_INTERNAL_AUTH_TOKEN, SPONGRAM_NEO4J_PASSWORD, SPONGRAM_CLOUD_LICENSE_PUBLIC_KEYS; optionally the Langfuse variables and any feature flag
graphiti.runtimeSecret (spongram-graphiti) OPENAI_API_KEY (the same value as SPONGRAM_INTERNAL_AUTH_TOKEN), NEO4J_USER, NEO4J_PASSWORD
neo4j.runtimeSecret (spongram-neo4j) NEO4J_AUTH in the form neo4j/<password>

SPONGRAM_ENCRYPTION_KEY is a Fernet key. It is mandatory with the Cloud control plane: queued jobs carry an encrypted context. Back it up separately; losing it makes already accepted jobs undecryptable.

The Helm chart

Chart spongram-cloud, version 0.1.0.

Templates

File Objects
api.yaml ServiceAccount (annotated with api.roleArn), Deployment spongram, Service spongram (ClusterIP, 8091), PodDisruptionBudget spongram-api (minAvailable: 1)
graphiti.yaml StatefulSet spongram-graphiti (one replica, a receipts volume claim), Service (ClusterIP, 8000)
neo4j.yaml StatefulSet spongram-neo4j (one replica, a data volume claim), Service (ClusterIP, 7687). Rendered when neo4j.enabled
migration.yaml ServiceAccount and Job spongram-migrate-<revision> as pre-install,pre-upgrade hooks. Rendered when migration.enabled
network.yaml NetworkPolicy spongram-internal-services when networkPolicy.enabled; Ingress spongram when ingress.enabled

The API container runs as a non-root user with a read-only root filesystem and all capabilities dropped. Its startup and readiness probes call /readyz; the liveness probe is a TCP check on the port, so an unhealthy background worker never restarts the pod. The Deployment rolls with maxUnavailable: 0 and maxSurge: 1.

The chart fixes these variables on the API container: SPONGRAM_EDITION=cloud, SPONGRAM_CLOUD_CONTROL_ENABLED=true, SPONGRAM_CLOUD_CUSTOMER_INSTALLATION=true, SPONGRAM_RUN_MIGRATIONS=false, SPONGRAM_GRAPHITI_URL=http://spongram-graphiti:8000 and LANGFUSE_TRACING_ENVIRONMENT=customer. On the Graphiti container it sets OPENAI_API_URL and OPENAI_BASE_URL to http://spongram:8091/_internal/v1/graphiti, SPONGRAM_CLOUD_JOB_RECEIPTS=true and SPONGRAM_EXECUTION_SPOOL=/receipts.

Values

Value Default Meaning
api.image "" (required) Spongram image. Pin it by digest
api.replicas 1 API replicas. Raise only after your own multi-replica qualification
api.serviceAccount spongram Name of the API ServiceAccount; must match the role trust policy
api.roleArn "" Application role ARN (application_role_arn output)
api.runtimeSecret spongram-runtime Kubernetes Secret loaded into the API environment
api.databaseUrl "" (required) SPONGRAM_DATABASE_URL: a DSN or aws-secretsmanager://<secret-id> for the runtime role
api.databaseAuth secret SPONGRAM_AWS_DB_AUTH: secret or iam
api.forwardedAllowIps 127.0.0.1 FORWARDED_ALLOW_IPS: address or CIDR of the ingress whose X-Forwarded-For is trusted
api.publicUrl "" (required) SPONGRAM_PUBLIC_URL
api.awsRegion "" AWS_REGION for the AWS SDK
api.rdsCaConfigMap spongram-rds-ca ConfigMap holding global-bundle.pem
api.resources requests 500m / 512Mi, limits 2 / 2Gi API container resources
migration.enabled false Render the migration Job
migration.serviceAccount spongram-migration ServiceAccount of the Job
migration.roleArn "" Migration role ARN (operator_role_arns.migration)
migration.databaseUrl "" (required when enabled) SPONGRAM_MIGRATION_DATABASE_URL for the schema-owner role
migration.adoptSchema "" 0033, legacy or 0045, once, for the first upgrade of an existing unjournalled database
graphiti.image "" (required) The patched spongram-graphiti image. Pin it by digest
graphiti.runtimeSecret spongram-graphiti Kubernetes Secret loaded into the Graphiti environment
graphiti.storageClass gp3-encrypted StorageClass of the receipt spool
graphiti.spoolSize 10Gi Size of the receipt spool
graphiti.resources requests 500m / 1Gi, limits 2 / 4Gi Graphiti container resources
neo4j.enabled true Deploy Neo4j from the chart
neo4j.image neo4j:5.26-community, pinned by digest Neo4j image
neo4j.runtimeSecret spongram-neo4j Kubernetes Secret loaded into the Neo4j environment
neo4j.uri bolt://spongram-neo4j:7687 Bolt URI given to the API and to Graphiti
neo4j.storageClass gp3-encrypted StorageClass of the graph volume
neo4j.size 100Gi Size of the graph volume
neo4j.resources requests 1 / 2Gi, limits 4 / 4Gi Neo4j container resources
ingress.enabled false Render the Ingress
ingress.className nginx Ingress class
ingress.host "" (required when enabled) Public host name
ingress.tlsSecret "" (required when enabled) TLS secret for that host
ingress.annotations {} Controller-specific annotations
networkPolicy.enabled true Render the NetworkPolicy

Values files hold references, never secret values.

Storage class

Both StatefulSets request a StorageClass named gp3-encrypted. Create it with the EBS CSI driver, KMS encryption, volumeBindingMode: WaitForFirstConsumer and a reclaim policy suited to data you intend to keep.

Graphiti's receipt spool has a single owner. Do not scale that StatefulSet.

Migration job

The API never runs DDL in this profile (SPONGRAM_RUN_MIGRATIONS=false). With migration.enabled=true, each helm install and helm upgrade first runs:

python -m spongram_proxy.cloud.install migrate [--adopt-schema=<value>]

with SPONGRAM_MIGRATION_DATABASE_URL and the migration service account. The Job applies each migration file once, grants SELECT, INSERT, UPDATE, DELETE on the tables and usage on the sequences to the runtime role (spongram_app unless --runtime-role says otherwise), and revokes that role's access to the migration journal. The API pods roll only after the Job succeeded. Details, including adoptSchema, are in Upgrades and migrations.

Ingress and network policy

When enabled, the Ingress routes these path prefixes to the API service, with TLS from ingress.tlsSecret:

Path Serves
/console The Cloud console: its session and administration API (/console/api/*); any other /console/… path redirects to /admin/…
/admin The admin application and its API (/admin/api/*)
/mcp The MCP endpoint
/v1 Brain-key APIs and the explorers
/documentation This documentation site

Everything else stays inside the cluster: /_internal/* (the inference proxy), /metrics, /healthz and /readyz are not routed. Scrape and probe them through the spongram Service.

Disable response buffering and raise read timeouts for /mcp and /v1/graph/stream with the annotations of your controller.

The NetworkPolicy allows ingress to the Graphiti (8000) and Neo4j (7687) pods only from pods labelled app: spongram. Egress control and isolation from other workloads are yours to apply at cluster or VPC level.

Observability with Langfuse

LLM tracing is optional (see Observability). Two layouts are possible:

  • A Langfuse service you already use (SaaS or elsewhere). Keep self_hosted_langfuse = false. Terraform creates nothing for Langfuse. Put LANGFUSE_BASE_URL, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and SPONGRAM_LANGFUSE_ENABLED=true in the runtime Secret. Traces leave the cluster over HTTPS.
  • A Langfuse server you host in the same account. Set self_hosted_langfuse = true and supply cache_auth_token. Terraform then also creates a Valkey replication group (ElastiCache, TLS required, encrypted at rest), a <name>/langfuse secret and a <name>-langfuse role limited to the langfuse/ prefix of the objects bucket. The Spongram chart does not deploy the Langfuse server itself.

With the Cloud control plane enabled, traces carry models, durations, token counts and status, and omit prompt and response content.

Validate without creating anything

terraform -chdir=deploy/aws init -backend=false
terraform -chdir=deploy/aws validate
helm lint deploy/helm/spongram -f /private/path/values.yaml
helm template spongram deploy/helm/spongram -f /private/path/values.yaml

None of these commands creates a resource. terraform apply and helm upgrade --install do.

After the pods are ready

  1. Check /readyz from inside the network.
  2. Open /admin/ (/console/ redirects there). On a new installation, create the first administrator: its name, identifier, a password of 12 to 256 characters, and the installation secret SPONGRAM_ADMIN_TOKEN.
  3. Note the deployment identifier and import the signed licence.
  4. Configure the inference provider. A customer installation has no default provider: inference answers 503 until this is done. The embedder must keep the dimension of any existing graph.
  5. Create an organisation, users and brains.

The Admin UI page documents the console.