Skip to content

deltabase deploy

Deploy infrastructure from configuration file

Deploy event stores and subscriptions from a deltabase.config.ts file.

Terminal window
deltabase deploy [options]

Or without global installation:

Terminal window
pnpx @delta-base/cli deploy [options]

OptionDescriptionDefault
--config <path>Path to config filedeltabase.config.ts
--api-key <key>DeltaBase API key$DELTABASE_API_KEY
--api-url <url>API URLhttps://api.delta-base.com
--dry-runPreview changes without applyingfalse
--verboseShow detailed outputfalse

Terminal window
pnpx @delta-base/cli deploy --api-key your-api-key
Terminal window
export DELTABASE_API_KEY=your-api-key
pnpx @delta-base/cli deploy
Terminal window
pnpx @delta-base/cli deploy --config ./config/production.ts
Terminal window
pnpx @delta-base/cli deploy --dry-run --api-key your-api-key
Terminal window
pnpx @delta-base/cli deploy --verbose --api-key your-api-key

The deploy command reads from deltabase.config.ts:

import type { InfrastructureConfig as DeltaBaseConfig } from '@delta-base/server';
const config: DeltaBaseConfig = {
eventStores: [
{
name: 'my-service-events',
description: 'Events for my service',
settings: {
retentionPeriodDays: 365,
maxStreamSizeBytes: 1073741824, // 1GB
},
subscriptions: [
{
id: 'users-projection',
eventFilter: ['user.created', 'user.updated', 'user.deleted'],
subscriberType: 'webhook',
webhook: {
url: process.env.WEBHOOK_URL || 'https://my-app.com/webhooks',
headers: {
Authorization: `Bearer ${process.env.WEBHOOK_TOKEN}`,
},
retryPolicy: {
maxAttempts: 5,
backoffMinutes: 2,
},
},
},
],
},
],
};
export default config;

The deploy command performs reconciliation - comparing your config to the current state and making only necessary changes.

ScenarioAction
In config, doesn’t existCreate
In config, exists with different settingsUpdate
In config, matches current stateNo change
ScenarioAction
In config, doesn’t existCreate
In config, exists with different settingsUpdate
Exists but not in configDelete
In config, matches current stateNo change

Warning: Subscriptions not in your config file will be deleted. This ensures your config is the single source of truth.


Deploying DeltaBase infrastructure...
Event Stores:
✓ my-service-events (created)
Subscriptions:
✓ users-projection (created)
Deployment complete!
DRY RUN - No changes will be applied
Event Stores:
+ my-service-events (would create)
Subscriptions:
+ users-projection (would create)
Run without --dry-run to apply changes.

1. Command line flag:

Terminal window
pnpx @delta-base/cli deploy --api-key your-api-key

2. Environment variable:

Terminal window
export DELTABASE_API_KEY=your-api-key
pnpx @delta-base/cli deploy

3. .env file:

.env
DELTABASE_API_KEY=your-api-key
Terminal window
source .env && pnpx @delta-base/cli deploy

name: Deploy Infrastructure
on:
push:
branches: [main]
paths:
- 'deltabase.config.ts'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Deploy DeltaBase
run: pnpx @delta-base/cli deploy
env:
DELTABASE_API_KEY: ${{ secrets.DELTABASE_API_KEY }}
WEBHOOK_URL: ${{ vars.WEBHOOK_URL }}
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}
deploy:
stage: deploy
image: node:20
script:
- npx @delta-base/cli deploy
only:
- main
variables:
DELTABASE_API_KEY: $DELTABASE_API_KEY

“Configuration not found”

Error: Could not find deltabase.config.ts

Ensure the file exists or use --config to specify the path.

“Authentication failed”

Error: Invalid API key

Check your API key is correct and has the necessary permissions.

“Validation error”

Error: Event store name must be 3-63 characters

Fix the validation error in your config file.

CodeMeaning
0Success
1Error

Always preview changes before applying:

Terminal window
pnpx @delta-base/cli deploy --dry-run

Treat deltabase.config.ts like any infrastructure code:

Terminal window
git add deltabase.config.ts
git commit -m "Add users projection subscription"
// Good
headers: {
Authorization: `Bearer ${process.env.WEBHOOK_TOKEN}`,
}
// Bad - never commit secrets
headers: {
Authorization: 'Bearer actual-secret-token',
}
Terminal window
# Development
pnpx @delta-base/cli deploy --config config/development.ts
# Production
pnpx @delta-base/cli deploy --config config/production.ts