# pier add

> Add a resource

URL: https://pier.run/docs/cli/reference/add

```bash
pier add <command>
```

Add a resource.

## Subcommands

### pier add app

```bash
pier add app [flags]
```

Add an app.

| Flag           | Value         | Default | Description                                                                                                   |
| -------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
| `--name`       | `STRING`      |         | App name                                                                                                      |
| `--plan`       | `STRING`      |         | App plan (e.g. app-s, app-m)                                                                                  |
| `--replicas`   | `0`           | `0`     | Number of replicas                                                                                            |
| `--autoscale`  | `STRING`      |         | Autoscale range min-max (e.g. 1-4); XOR with --replicas                                                       |
| `--trigger`    | `TRIGGER,...` |         | Autoscale trigger type:value (cpu:70, memory:80, rps:50, latency:250ms); repeatable                           |
| `--idle-after` | `STRING`      |         | Zero-traffic window before scale-to-zero (with --autoscale 0-N)                                               |
| `--image`      | `STRING`      |         | Container image (static-image flow, skips build)                                                              |
| `--port`       | `INT`         |         | Container port (required with --image)                                                                        |
| `--template`   | `STRING`      |         | Scaffold from a starter template (e.g. node\_hono, python\_fastapi, go\_fiber, rust\_axum, dockerfile\_caddy) |
| `-y`, `--yes`  |               |         | Skip confirmation prompt                                                                                      |
| `--stage`      |               |         | Write the change to pier.yaml only — apply later with 'pier deploy'                                           |

### pier add site

```bash
pier add site [flags]
```

Add a static site.

| Flag          | Value    | Default | Description                                                                                           |
| ------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------- |
| `--name`      | `STRING` |         | Site name                                                                                             |
| `--template`  | `STRING` |         | Scaffold from a starter template (e.g. site\_nextjs, site\_astro, site\_vite, site\_hugo, site\_html) |
| `-y`, `--yes` |          |         | Skip confirmation prompt                                                                              |
| `--stage`     |          |         | Write the change to pier.yaml only — apply later with 'pier deploy'                                   |

### pier add pg

```bash
pier add pg [flags]
```

Add a Postgres instance.

| Flag           | Value    | Default | Description                                                         |
| -------------- | -------- | ------- | ------------------------------------------------------------------- |
| `--name`       | `STRING` |         | Postgres cluster name (CNPG cluster / Pier resource name)           |
| `--default-db` | `STRING` |         | Default Postgres database name created with the cluster (required)  |
| `--plan`       | `STRING` |         | Sizing plan (e.g. pg-s, pg-m, pg-l)                                 |
| `--replicas`   | `0`      | `0`     | Number of replicas                                                  |
| `--pg-version` | `STRING` |         | Postgres major version                                              |
| `-y`, `--yes`  |          |         | Skip confirmation prompt                                            |
| `--stage`      |          |         | Write the change to pier.yaml only — apply later with 'pier deploy' |

### pier add bucket

```bash
pier add bucket [flags]
```

Add a bucket.

| Flag          | Value    | Default | Description                                                         |
| ------------- | -------- | ------- | ------------------------------------------------------------------- |
| `--name`      | `STRING` |         | Bucket name                                                         |
| `--access`    | `""`     |         | Access level: public or private                                     |
| `-y`, `--yes` |          |         | Skip confirmation prompt                                            |
| `--stage`     |          |         | Write the change to pier.yaml only — apply later with 'pier deploy' |

### pier add volume

```bash
pier add volume [flags]
```

Add a persistent volume.

| Flag           | Value    | Default | Description                                                                                                          |
| -------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| `--name`       | `STRING` |         | Volume name                                                                                                          |
| `--size`       | `""`     |         | Size (e.g. 1GB, 5GB)                                                                                                 |
| `--durability` | `""`     |         | Durability tier: standard (node-local, default) or ha (replicated, survives node failure). Immutable after creation. |
| `-a`, `--app`  | `STRING` |         | Attach to an app (slug or slug/target)                                                                               |
| `--mount`      | `STRING` |         | Mount path inside the app (required with --app non-interactively)                                                    |
| `-y`, `--yes`  |          |         | Skip confirmation                                                                                                    |
| `--stage`      |          |         | Write the change to pier.yaml only — apply later with 'pier deploy'                                                  |

### pier add domain

```bash
pier add domain [<domain>] [flags]
```

Add a custom domain.

| Argument   | Required | Description                          |
| ---------- | -------- | ------------------------------------ |
| `<domain>` | no       | Domain to add (e.g. app.example.com) |

| Flag           | Value    | Default | Description                                                         |
| -------------- | -------- | ------- | ------------------------------------------------------------------- |
| `-a`, `--app`  | `STRING` |         | App ref (slug or slug/target)                                       |
| `-s`, `--site` | `STRING` |         | Site ref (slug or slug/target)                                      |
| `-y`, `--yes`  |          |         | Skip confirmation                                                   |
| `--stage`      |          |         | Write the change to pier.yaml only — apply later with 'pier deploy' |

### pier add target

```bash
pier add target <app> <name> [flags]
```

Add a deployment target to an app or site.

| Argument | Required | Description                                |
| -------- | -------- | ------------------------------------------ |
| `<app>`  | yes      | App or site (name)                         |
| `<name>` | yes      | New target name (slug-shaped, e.g. canary) |

| Flag           | Value    | Default | Description                                          |
| -------------- | -------- | ------- | ---------------------------------------------------- |
| `--branch`     | `STRING` |         | Git branch that deploys this target                  |
| `--plan`       | `STRING` |         | Sizing plan (e.g. app-s, app-m)                      |
| `--dockerfile` | `STRING` |         | Dockerfile path override (relative to build context) |
| `-y`, `--yes`  |          |         | Skip confirmation prompt                             |

[Global flags](/docs/cli/reference#global-flags) apply to every command.

## Examples

```bash
pier add app --name api --plan app-s                      # build from ./Dockerfile
pier add app --name whoami --image traefik/whoami --port 80
pier add pg --name main --plan pg-s --default-db app
pier add domain api.example.com --app api
pier add target api canary --branch main
pier add app --stage                                       # write pier.yaml only
```

## Behaviour

* `add` declares; the resource is created on the platform immediately unless `--stage`
  is set, in which case it is written to `pier.yaml` and created by the next `pier
  apply` or `pier deploy`.
* `add` is paired with `rm`; `set` changes an existing resource. `create` is used only for
  artifacts that are taken rather than declared (`snapshots create`, `backups create`).
