Skip to content

Feature request: --env flag for brev create #372

@robobryce

Description

@robobryce

Use case

I'm building an orchestrator that programmatically spawns Brev instances. Each spawned instance needs to come up with a small set of bootstrapping environment variables set (a callback URL and a one-time short-lived token, used by the instance's startup script to fetch the rest of its configuration from my orchestrator).

Today, brev create accepts --startup-script / -s but has no way to pass environment variables to that script. The workarounds I'm considering all have downsides:

  1. Bake the env vars into the startup-script string itself. Works, but means I'm constructing shell that interpolates secrets, which is awkward to do safely (quoting, escaping). It also leaks the values into the script text that's stored on the Brev side.
  2. Have the script fetch its bootstrapping config from a known endpoint by instance ID. Possible, but my orchestrator doesn't know the instance's identity until after brev create returns, so the endpoint can't gate by instance — and gating by source IP requires a round-trip after creation completes.
  3. Use cloud-init user-data. Brev doesn't surface that.

Proposal

Add a --env KEY=VALUE flag (repeatable) and a --env-file <path> flag to brev create, mirroring the convention from docker run, gcloud compute instances create --metadata, and aws ec2 run-instances --user-data. The values would be available as environment variables when the startup script runs.

brev create my-instance \
  -s @setup.sh \
  --env CALLBACK_URL=https://orchestrator.example.com \
  --env BOOTSTRAP_TOKEN=xxxxxxxx

Or:

brev create my-instance -s @setup.sh --env-file ./bootstrap.env

This is a common pattern in every other cloud CLI I've used and would unblock a clean separation between "Brev knows how to start a VM and run a script" and "my orchestrator's own bootstrap flow."

Happy to send a PR if there's interest and a hint about where this would slot in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions