Bring your own cloud: Connect your AWS account
Connecting an account takes about ten minutes. You need to be the owner of the KiviDB organization, and able to create a CloudFormation stack with an IAM…
Connecting an account takes about ten minutes. You need to be the owner of the KiviDB organization, and able to create a CloudFormation stack with an IAM role in the AWS account. Before you start, have ready:
- the 12-digit AWS account ID
- the regions you want databases in
- the name of an existing S3 bucket in that account, for backups
- in each region, the VPC ID and one subnet ID per availability zone, each subnet with a route to an internet gateway
See Requirements for details.
Open Settings → Cloud accounts and click Connect a cloud account. Your progress is saved after each step, so you can close the dialog and come back: an unfinished connection shows as Pending, and Continue setup picks up where you left off.
1. Choose the cloud

Choose AWS. To connect a Google Cloud project instead, see Connect your Google Cloud project, or for Azure Connect your Azure subscription.
2. Enter the account details

- Name: what this connection is called in KiviDB, for example Production AWS.
- AWS account ID: the 12-digit ID of the account.
- Regions: every region KiviDB may create databases in. The role you create in the next step works only in these regions.
- Backup bucket: an existing S3 bucket in that account. Backups are written
under
kividb/, and KiviDB cannot read or change anything else in the bucket. - Allow public endpoints: leave this on. Databases get an internet address that only the IPs on their allowlist can reach. It is required for now: private-only databases are not available yet.
Click Create connection. These details are fixed from here on; to change them later you disconnect the account and connect it again, so choose every region you expect to need. Each AWS account can be connected to an organization once.
3. Create the role

KiviDB works in your account through a role you create from its CloudFormation template.
-
Click Download template to save
kividb-byoc-role.yaml. -
Click Open CloudFormation (or open CloudFormation in the AWS console yourself, signed in to the right account) and create a stack, choosing Upload a template file and the file you downloaded.
-
Give the stack a name, for example
kividb-byoc, and copy each value shown in KiviDB into the parameter with the same name:Parameter What it is ConnectionIdThis connection's ID. It names the role, so one AWS account can hold several KiviDB connections. ExternalIdA secret unique to this connection. The role only trusts KiviDB when it presents this exact value. KiviDBApiRoleArn,KiviDBWorkerRoleArnKiviDB's own roles, the only ones allowed to use your role. AllowedRegionsThe regions you chose. SnapshotBucketNameYour backup bucket. -
Acknowledge that the stack creates an IAM role, create the stack, and wait until its status is CREATE_COMPLETE.
The stack creates one role, KiviDBManagement-<connection ID>. One AWS
account can hold several connections (for example from two KiviDB
organizations): each has its own stack and its own role. To see what it can do, read
Permissions and security or the template
itself.
Allow uploads from the KiviDB console (optional)
Only needed to upload .kdb files from the KiviDB console into this
account. Backups, restores and databases work without it.
An upload goes from your browser straight into your backup bucket, through a
short-lived link signed by KiviDB. S3 only accepts that from a browser when the
bucket's CORS configuration allows the KiviDB console's site. The role cannot
change a bucket it did not create, so KiviDB shows one command, under
Optional: allow uploads from the KiviDB console, with your bucket and the
console's site filled in. Run it once in
AWS CloudShell, signed in to
the account (jq is already installed there):
B='YOUR_BACKUP_BUCKET'; O='https://kividb.io'
if CUR="$(aws s3api get-bucket-cors --bucket "$B" --query CORSRules --output json 2>kividb-cors.err)"; then :
elif grep -q NoSuchCORSConfiguration kividb-cors.err; then CUR='[]'
else cat kividb-cors.err; CUR=''; fi
if [ -z "$CUR" ]; then echo "Nothing changed: the bucket's CORS rules could not be read."
elif printf '%s' "$CUR" | jq -e --arg o "$O" 'any(.[]; ((.AllowedOrigins // []) | any(. == $o or . == "*")) and ((.AllowedMethods // []) | any(. == "PUT")) and ((.AllowedHeaders // []) | any(ascii_downcase == "content-type" or . == "*")))' >/dev/null; then
echo "Uploads from $O are already allowed."
else
printf '%s' "$CUR" | jq --arg o "$O" '{CORSRules: (. + [{AllowedOrigins: [$o], AllowedMethods: ["PUT"], AllowedHeaders: ["Content-Type"], ExposeHeaders: ["ETag"], MaxAgeSeconds: 3600}])}' >kividb-cors.json
aws s3api put-bucket-cors --bucket "$B" --cors-configuration file://kividb-cors.json && echo "Done: uploads from $O are allowed, next to the bucket's other CORS rules."
fi
It reads the bucket's CORS rules, and adds one (PUT from the console's site,
with the Content-Type header, ETag exposed, cached for an hour) next to
them: rules you already have are kept, and nothing changes when one of them
already allows these uploads. If the rules cannot be read for any reason other
than there being none, it stops without writing anything. The rule only lets a
browser on the KiviDB site send a request; the request still needs a link
signed by KiviDB.
You can run it at any time, including after the connection is verified: the same section is under Role template on the connection in Settings → Cloud accounts.
4. Paste the role ARN

In CloudFormation, open the stack's Outputs tab, copy the RoleArn
value, and paste it into KiviDB. It looks like
arn:aws:iam::123456789012:role/KiviDBManagement-<connection ID>, with your
account ID in it.
5. Choose the network

For each region, enter:
- VPC ID: the existing VPC your databases should run in.
- Subnet IDs: one subnet in each availability zone you want databases and replicas in, separated by commas, up to six. A high-availability (Pro) database places its nodes in different zones, so give at least two.
Each subnet must have a route to an internet gateway. KiviDB does not change your VPC, subnets or route tables. It adds one security group per database, and nothing else, to your network.
6. Verify

Click Verify. KiviDB uses the role to confirm it belongs to your account, reads the network you chose in each region, and checks the backup bucket. Nothing is created. Each check is listed with its result:
| Check | What it confirms |
|---|---|
| Role belongs to this account | The role ARN is in the AWS account you entered. |
| KiviDB can use the role | The role exists and trusts KiviDB with this connection's ExternalId. |
| Role answers from this account | Using the role really acts in your account. |
| Network in region | The VPC and subnets exist, the subnets are in that VPC, each is in a different availability zone, and each routes to an internet gateway. |
| Backup bucket is reachable | The bucket exists, belongs to your account, and KiviDB can use its kividb/ prefix. |
| Browser uploads allowed | The bucket's CORS lets the KiviDB console upload .kdb files. Only ever a warning, never a failure: run the optional command to fix it. |
When every check passes, the connection is Verified and you can create databases in it. If a check fails, the message says what to fix; see Troubleshooting.
Manage a connection

Settings → Cloud accounts lists every connection with its status:
| Status | Meaning |
|---|---|
| Verified | Ready. New databases can be created in it. |
| Pending | Setup isn't finished. Open it and click Continue setup. |
| Check failed | The last check found a problem, shown at the top of the connection. Fix it and click Check again. |
Click a connection to see its details and these actions:
- Check again runs the verification again, for example after you change something in AWS.
- Edit network changes the VPC or subnets for a region. Verify again afterwards; new databases use the network once it is verified.
- Download template is always available. When KiviDB publishes a new version of the role, download it and update your stack in CloudFormation (Update, Replace existing template), keeping the same parameter values, then click Check again.
- Disconnect removes the connection from KiviDB. See Disconnect an account.
A failed check stops new databases from being created in the account until it passes again. Databases already running there are not affected, and KiviDB keeps managing them as long as the role still works.