Docs / Add-ons

Add-ons.

Add-ons are managed datastores - Postgres, Redis, MySQL, MongoDB - that you attach to a service. Attaching one injects its connection string as a sealed environment variable into the target service. No credential copy-paste, no secret leaks, no manual wiring.

What an add-on is

An add-on is a Fieldwick service whose source-type is set to one of the managed database types: postgres, redis, mysql, or mongodb. It is a first-class service in your project - it has its own service ID, its own logs, and its own resource budget. The only difference from an application service is that Fieldwick manages the datastore process and exposes an attachment API that lets other services consume its credentials without ever seeing the raw value.

Once you attach an add-on to a target service, Fieldwick writes the connection string into the target as a sealed environment variable. Sealed variables appear in fieldwick env list with their name visible but their value redacted. They are injected at runtime so your source code never contains them.

Create an add-on

Create an add-on the same way you create any service - with fieldwick services create - but pass a database type for --source-type. The example below creates a Postgres add-on named db inside a project:

fieldwick services create \
  --name db \
  --project <project-id> \
  --source-type postgres

The CLI prints the new service ID. Keep it - you will pass it to the attach command next. Valid values for --source-type are postgres, redis, mysql, and mongodb. For Docker-based app services, pass docker instead.

Attach to a target service

Once the add-on service exists, attach it to any service in the same project. The attachments attach command takes the add-on ID and the target service ID:

fieldwick attachments attach <addon-id> <target-svc-id>

Fieldwick immediately writes the connection string as a sealed environment variable into the target service and triggers a restart so the new variable is live. The variable name follows the pattern DATABASE_URL for Postgres and MySQL, REDIS_URL for Redis, and MONGODB_URI for MongoDB. Your application code reads it from the environment like any other variable.

List attachments

To see which add-ons are attached to a given service, pass the target service ID to attachments list:

fieldwick attachments list <target-svc-id>

The output shows the attachment ID, the add-on service name and ID, the injected variable name, and the date the attachment was created. Add --json to get machine-readable output suitable for scripting or CI pipelines.

Detach an add-on

Detaching removes the sealed variable from the target service and restarts it. The add-on service itself keeps running - detaching does not delete data. Use the attachment ID from attachments list:

fieldwick attachments detach <attachment-id>

If you want to delete the datastore entirely, delete the add-on service with fieldwick services delete <addon-id>. This is irreversible and destroys all data stored in the instance. Detach before deleting if the target service is still running.