- Running an initial sync from your DB to Oso Cloud.
- Keeping facts up-to-date in production with Oso Sync.
- Configuration for PostgreSQL, MongoDB, and CSV.
- Limitations and best practices.
Sync facts in production
Oso Sync (available on Startup and Growth plans) updates Oso Cloud to match your application database. Typical flow:- Decide how to represent authorization data as facts.
- Run a one-time initial sync to populate Oso Cloud.
- Keep facts in sync using dual writes and periodic reconciliation.
Initial sync with Oso Sync
Oso Sync connects to your data source(s) and runs a configured query for each fact type. Run from the CLI:Configure Oso Sync
Yourreconcile.yaml maps data sources to fact types. We currently support the following data sources: PostgreSQL, MongoDB, and Comma-separated Values (CSV).
PostgreSQL
version: optional, defaults to1.source: optional, defaults topostgres.facts:- Fact type uses positional variables (
_) that map to query columns in order. dbmatches an entry indbs.queryreturns all facts of that type.- Example:
has_relation(Repository:_, String:parent, Organization:_)has variables in the first and third arguments.repository.public_idfills the first argument (Repository), andorganization.public_idfills the third argument (Organization).
- Fact type uses positional variables (
dbs:- Maps unique names to database connection details.
connection_stringis a PostgreSQL connection URI or an environment variable:connection_string: $ENV_VAR_NAME.ssl: optional block to configure SSL/TLS settings.ca_file: optional, path to a custom CA certificate file.use_system_certs: optional, opt-in to using the system’s certificate store; defaults tofalse.ssl_mode: optional, if you have specified aca_file, defaults torequire; otherwise, defaults toprefer.require: fail the connection if the server does not support SSL.prefer: use SSL if the server supports it, but fall back to no SSL otherwise.
MongoDB
version: must be1.source: must bemongodb.facts:- Fact type uses positional variables (
_) that map to query columns in order. collection: name containing fact data.fields: maps to positional arguments in fact type.- At most one field can have
is_array: true (automatically unwound).
- At most one field can have
querycan be either:find: standard find query.aggregate: aggregation pipeline (cannot use$out).- Example:
has_relation(Repository:_, String:parent, Organization:_)has variables in the first and third arguments.
- Fact type uses positional variables (
dbs:connection_stringmust be a valid MongoDB connection URI or an environment variable:connection_string: $ENV_VAR_NAME.
Comma-separated Values (CSV)
version: must be1.source: must becsv.facts:- Fact type uses positional variables (
_) that map to query columns in order. fields: must match the CSV header exactly.- Order must match positional arguments in the fact type.
path: local path to CSV file.- Example:
has_relation(Repository:_, String:parent, Organization:_)has variables in the first and third arguments.
- Fact type uses positional variables (
Oso Sync limitations
For Oso Sync concurrency and data size limits, see Service limits. The diff may include transient false positives due to our comparing a point-in-time snapshot of your database to Oso Cloud, which continues to receive changes. Transient false positives should not appear on successive invocations of Oso Sync and do not indicate issues with how your application updates facts in Oso Cloud. Each invocation of Oso Sync processes up to5_000_000 changes across both inserts and deletes per fact type. For example, syncing a fact type with 20_000_000 new records will require at least four Oso Sync invocations, and syncing a fact type with 2_500_001 insertions and 2_500_000 deletions will require at least two invocations.
Docker
We publish a wrapped up version of the CLI for Oso Sync atpublic.ecr.aws/osohq/reconcile:latest.
To use it, build your own image on top of this using a Dockerfile like this:
docker build -t reconcile-tool -f reconcile-tool.Dockerfile --build-arg="CONFIG_PATH=./reconcile.yaml" --platform linux/amd64 ..