IAM Authentication
Use AWS RDS or GCP Cloud SQL IAM authentication with mirrord DB branching
mirrord supports IAM authentication for AWS RDS and GCP Cloud SQL. Credentials come from the target pod: either from its environment, just like connection URLs, or from its cloud identity (IRSA (min version operator:3.186.0) / EKS Pod Identity on AWS, Workload Identity on GCP). For general concepts and the full list of config fields, see the DB Branching overview.
Connecting to the branch
IAM only authenticates against the real cloud database - the branch is a plain database pod the cloud provider knows nothing about, so an IAM token is not a valid password there. For PostgreSQL branches, mirrord solves this by running the branch pod with trust authentication whenever iam_auth is set: the branch accepts whatever credentials your application already sends, the IAM token included, so the application connects without any changes. The source database is unaffected, and branches without iam_auth keep regular password authentication.
AWS RDS IAM Authentication
Minimal Configuration
Uses the standard AWS environment variables already present in the target pod.
{
"feature": {
"db_branches": [
{
"type": "pg",
"version": "16",
"connection": { "url": "DATABASE_URL" },
"iam_auth": { "type": "aws_rds" }
}
]
}
}Credential sources
The branch init container needs AWS credentials to sign the RDS auth token. mirrord supports both ways a pod usually holds them:
Static keys: if the target pod has
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY(and optionallyAWS_SESSION_TOKEN) in its environment, mirrord copies them to the branch pod.IRSA / EKS Pod Identity: if the target pod has no static keys, the branch pod runs under the target pod's service account and receives the same IAM role automatically. The minimal configuration above is all you need.
Default AWS environment variables
mirrord reads the following variables from the target pod, not from your local shell.
region
AWS_REGION, AWS_DEFAULT_REGION
access_key_id
AWS_ACCESS_KEY_ID
secret_access_key
AWS_SECRET_ACCESS_KEY
session_token
AWS_SESSION_TOKEN
Custom AWS environment variables
Use this only if your pod uses non-standard variable names.
Apps that build the connection URL at runtime
Some applications never read a connection URL from the environment. At startup they look up the database address in AWS Systems Manager Parameter Store (SSM), sign an IAM token, and build the URL in code. mirrord cannot read SSM, and the application would ignore the branch URL mirrord sets for it anyway.
This works without changing the application or the cluster, as long as the code already has a switch that makes it read a URL from an environment variable, for example a flag for local development:
valueis the source URL the branch copies from. It has no password: withiam_auth, the branch init container signs its own IAM token with the target pod's service account. The variable does not need to exist in the pod spec.variableis the name your local process reads. mirrord sets it to the branch URL.nameis the database name fromvalue. The operator never reads the literal URL, so it needs the name to hand your process a branch URL for your database rather thanpostgres. mirrord3.278.0and later take it fromvaluewhen you leavenameout; set it yourself on older CLIs.env.overrideflips the switch (USE_SSMhere; use your application's own flag) on your machine only, so the application readsDATABASE_URLinstead of building the URL itself. The deployed workload is not touched.
To avoid copying the URL into the config, point connection.url at the same parameter your application reads instead, with an AWS SSM Parameter Store source. The branch init container then reads the parameter with the target pod's service account. In that case name is required, because mirrord never sees the URL.
When the branch copies data (copy.mode schema or all), use sslmode=require in value, even when the application uses verify-full. The branch init container has no copy of the RDS certificate authority to verify against, so verify-full fails the copy. require still encrypts it. An empty branch reads nothing from the source, so any sslmode works there.
GCP Cloud SQL IAM Authentication
Minimal Configuration
Uses the standard GOOGLE_APPLICATION_CREDENTIALS file path from the target pod. If the target pod uses Workload Identity instead of a credentials file, the same configuration works: the branch pod runs under the target pod's service account and receives the same GCP identity, so no credential fields are needed.
Default GCP environment variables
credentials_path
GOOGLE_APPLICATION_CREDENTIALS
project
GOOGLE_CLOUD_PROJECT, GCP_PROJECT, GCLOUD_PROJECT
Custom GCP credentials
You can override the default behavior in one of the following ways.
Option 1: Inline JSON credentials Load the service account JSON directly from an environment variable.
Option 2: Custom credential file path
Read credentials from a file path provided via an environment variable (for example, a mounted Kubernetes Secret).
Required Database Settings
GCP Cloud SQL requires TLS. Make sure your DATABASE_URL includes: sslmode=require
The sslmode=require only applies to the source. The branch connection your application receives carries the branch pod's own TLS mode (sslmode=disable for a regular branch pod), so the app does not demand TLS the branch cannot serve. See Branch Query Parameters to override it.
Last updated
Was this helpful?

