# pier apply

> Converge pier.yaml: add, set and remove resources — never rolls a workload

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

```bash
pier apply [<file>] [flags]
```

Converge pier.yaml: add, set and remove resources — never rolls a workload.

## Arguments

| Argument | Required | Description                              |
| -------- | -------- | ---------------------------------------- |
| `<file>` | no       | Path to pier.yaml (default: auto-detect) |

## Flags

| Flag          | Value              | Default | Description                                                                                         |
| ------------- | ------------------ | ------- | --------------------------------------------------------------------------------------------------- |
| `--dry-run`   |                    |         | Preview changes without applying                                                                    |
| `-y`, `--yes` |                    |         | Skip confirmation prompt                                                                            |
| `--prune`     |                    |         | Delete resources not in pier.yaml                                                                   |
| `--all-envs`  |                    |         | Apply all environments (default: current env only)                                                  |
| `--purge`     |                    |         | Deletes in this apply skip the 30-day recovery window (torn down immediately)                       |
| `--rename`    | `KIND.OLD=NEW,...` |         | Apply a rename in place instead of delete+create (KIND.OLD=NEW, e.g. apps.api=gateway). Repeatable. |

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

## Examples

```bash
pier apply                  # converge the current environment to pier.yaml
pier apply --dry-run        # print the plan, change nothing
pier apply --all-envs -y    # every environment in the file
pier apply --prune          # also remove what pier.yaml no longer declares
```

## Behaviour

* `apply` creates, changes and removes declarations. It never builds and never rolls a
  running target; `pier deploy` does that and implies `apply`.
* Removals keep data for 30 days in [trash](/docs/concepts#trash); `--purge` skips the
  window.
* Renaming a resource is delete + create unless `--rename KIND.OLD=NEW` says otherwise.

## See also

[`pier deploy`](/docs/cli/reference/deploy) · [`pier config`](/docs/cli/reference/config) ·
[Concepts: apply, deploy, staged](/docs/concepts#apply-deploy-staged)
