Skip to content
Latchkey

influx bucket create: Buckets for Tests in CI

influx bucket create makes a new InfluxDB 2.x bucket in an org, optionally with a retention period after which data expires.

A bucket is the InfluxDB 2.x container for time-series data, the rough equivalent of a database. Tests create a throwaway bucket, write to it, and drop it.

What it does

influx bucket create registers a named bucket under an org with an optional retention period. The bucket subcommands (create, list, delete) manage these containers. Writes and queries target a bucket by name, so a test fixture usually creates one up front.

Common usage

Terminal
influx bucket create --name app --org acme --retention 24h
influx bucket list --org acme
influx bucket delete --name app --org acme

Options

FlagWhat it does
-n, --name <name>Bucket name
-o, --org <name>Organization that owns the bucket
-r, --retention <dur>Retention period, e.g. 24h or 0 for infinite
-t, --token <token>API token (or set via influx config)
--host <url>Server URL, e.g. http://localhost:8086

In CI

A short retention like 24h keeps a long-lived test instance from accumulating data, though for an ephemeral container it does not matter. If influx setup already created an initial bucket, reuse it instead of creating another. Bucket names must be unique within an org, so guard reruns by deleting first or checking the list.

Common errors in CI

"Error: failed to create bucket: 401 Unauthorized" means a bad token. "could not find org \"acme\"" means the org name is wrong or setup has not run. "bucket with name app already exists" on a rerun means you need to delete it first or treat existence as success.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →