S3
Spin up an isolated clone of your remote S3 bucket with mirrord
This page covers branching for S3 object storage buckets. For the general concepts, the full list of config fields, and how a session behaves, see the DB Branching overview.
Unlike the engines mirrord runs as a database server, an S3 branch is not a pod in your cluster: the operator has the storage provider create a new bucket in your own cloud account, clones the source bucket's settings and (optionally) its objects into it, and points your application's bucket environment variable at the clone. Your code keeps reading the same variable and never learns it is writing to a throwaway bucket.
Providers
The provider field selects which storage service hosts the branch bucket:
provider
Service
"AWS" (default)
Everything on this page applies to every provider unless a section says otherwise; the Permissions section is provider-specific, since each provider has its own way of granting the operator access.
How It Works
The operator reads the name of the source bucket from the target workload, out of the environment variable named by the
bucketparam.It creates a branch bucket in the source bucket's region, named
mirrord-<10 random letters>-<source bucket name>. When that would exceed the 63-character limit on bucket names, the source part is replaced by a hash of the source bucket's name.It clones the source bucket's configuration and, depending on the copy mode, its objects.
Every environment variable your config lists for the
bucketparam is rewritten to the branch bucket's name, so your local process reads the clone. With avalue_pattern, only the matched part of the value is swapped and the rest of the string stays intact.When the branch's TTL expires or you run
mirrord db-branches destroy, the operator empties the branch bucket and deletes it.
The clone runs with the operator's own cloud credentials and happens entirely inside the provider - objects never pass through the cluster or your machine.
Basic Configuration
provider is optional and defaults to "AWS".
Fields That Don't Apply
An S3 branch has no branch pod and no database server, so several fields from the overview are not accepted or have no effect:
version, image
There is no container to run.
location
The branch always lives in your cloud account, never in the cluster or on your machine.
profile
Branch config profiles configure a branch pod; there is no s3BranchConfig in the Helm chart. A branch that sets profile fails with an error naming the field.
migrations
Schema migrations run against a database server.
iam_auth
The operator uses its own cloud identity for the clone - see Permissions.
name
A bucket is not a server hosting several databases.
The usual id, ttl_secs/ttl_mins and creation_timeout_secs all work as they do for any other branch. Since cloning a large bucket takes time, raise creation_timeout_secs (default 60) when the session fails with a timeout while the branch is still being prepared.
Naming the Source Bucket
The single connection param an S3 branch takes is bucket - the environment variable on the target that holds the source bucket's name. The field is called source, but connection is accepted as an alias, so configs that mirror the other engines work too:
The type field selects how the variable is resolved on the target, exactly as for the other engines, and is auto-detected when omitted:
The value is as flexible as any other engine's param - see Connection Modes for the full list of sources. For example, a Kubernetes Secret:
a literal value:
or a regex picking the bucket name out of a larger variable, so only that part of the value is swapped:
An array of sources works as well: the first entry locates the source bucket, and all entries are rewritten to the branch bucket during the session.
Copy Modes
"empty" (default)
The bucket and its settings, with no objects
Apps that write their own fixtures, or source buckets too large to clone
"all"
The settings plus the objects selected by objects
Reproducing a production-like bucket for debugging
With "mode": "all", the optional objects field is a list of regular expressions matched against object keys. An object is copied when it matches any of them; omitting the field (or passing an empty list) copies every object.
Patterns are not anchored automatically, so ^ and $ are yours to add. An invalid expression fails the branch with an error naming the pattern.
What Gets Cloned
Bucket settings are cloned best-effort: a setting the operator cannot read (a missing permission) or that the branch bucket rejects is skipped rather than failing the branch. The branch reports what it did in its Ready condition - how many objects were copied, how many were skipped, and which settings were left behind - so a user whose objects or settings are missing can tell why:
Object ownership controls
Event notifications and EventBridge
Public access block
Replication
Bucket tags
Lifecycle rules, access logging, static website hosting, Object Lock
Versioning (when enabled on the source)
MFA delete
Default encryption
Per-object ACLs and storage classes
CORS rules
Bucket policy, with the source bucket's ARNs rewritten to the branch bucket
Objects are copied at their latest version, with their metadata and tags. A suspended-versioning source leaves the branch unversioned, which behaves the same for new writes.
Because the bucket policy is carried over with the bucket name swapped, access that your source bucket grants through its resource policy keeps working on the branch. Access granted through an identity policy does not - see below.
Permissions
The operator clones buckets with its own cloud credentials, not the target's. The rest of this section is specific to "provider": "AWS".
The operator
The operator's AWS client is built from the default credentials provider chain. The easiest way to provide the credentials is IAM role assumption: assign an IAM role to the operator's service account (see AWS's documentation), which the sa.roleArn setting in the mirrord-operator Helm chart annotates for you.
Branch buckets are always named with the mirrord- prefix, so the permissions the operator needs on its own buckets can be scoped to arn:aws:s3:::mirrord-*, while the source buckets only need read access:
The first statement covers the buckets your developers branch. Instead of listing them, you can apply the statement to all buckets in the account and limit it with conditions - for example a tag like
branchable=trueset on every bucket you want to allow.The second statement covers the branch buckets.
s3:ListBucketon the source is what lets the operator locate its region and enumerate the objects to copy;s3:ListBucketVersionsands3:DeleteObjectVersionare what let it empty a versioned branch bucket before deleting it.
Your application
Your local application (and the target workload) reaches the branch bucket with its own credentials, not the operator's. If its access to the source bucket comes from an IAM identity policy rather than the bucket's policy, extend that policy to the branch buckets - again, arn:aws:s3:::mirrord-* and arn:aws:s3:::mirrord-*/* cover all of them.
Last updated
Was this helpful?

