# Chalk CLI Reference: Environments
source: https://docs.chalk.ai/cli#environments

Inspect and manage Chalk environments — view an environment's configuration, edit its description and metadata, and patch, update, suspend, or resume it.

## `chalk environment config`
source: https://docs.chalk.ai/cli?command=environment_config

```bash
chalk environment config
```

Use the `chalk environment config` command to dump the active environment's configuration as YAML. The output includes spec config, environment variables, private pip repositories, and configured secrets — the same fields accepted by `chalk environment update`.

**Example**

```
$ chalk environment config
id: env_123456789
name: production
specs_config_json:
  resource_groups:
    - resource_group_name: default
      services:
        engine-grpc:
          ...
additional_env_vars:
  LOG_LEVEL: info
```

## `chalk environment update`
source: https://docs.chalk.ai/cli?command=environment_update

```bash
chalk environment update
```

Use the `chalk environment update` command to update environment settings from a YAML file.

The YAML file can include:

- specs_config: Configuration for feature stores, resolvers, etc.
- additional_env_vars: Environment variables to set
- private_pip_repositories: Private PyPI repository URLs
- online_store_secret: Name of secret containing online store credentials
- feature_store_secret: Name of secret containing feature store credentials
- environment_buckets: Object-storage bucket names for this environment. All four sub-fields (`dataset_bucket`, `plan_stages_bucket`, `source_bundle_bucket`, `model_registry_bucket`) are individually optional; omitted fields are preserved from the current environment. At least one sub-field must be set. The common case is adding a `model_registry_bucket` to an environment that already has the others.

**Flags**

- `--env-id <env_123456789>` (string)
  The id of the environment to update.
- `--config-file <environment.yaml>` (string)
  Path to YAML file containing environment configuration.

**Example**

```
$ chalk environment update --env-id env_123456789 --config-file environment.yaml
Updated environment 'production'

# Example environment.yaml (add a model_registry_bucket without touching the others):
#   environment_buckets:
#     model_registry_bucket: gs://my-model-registry-bucket
```

## `chalk environment update_metadata`
source: https://docs.chalk.ai/cli?command=environment_update_metadata

```bash
chalk environment update-metadata
```

Use the `chalk environment update-metadata` command to edit the descriptive fields attached to the active environment: its Markdown description and its free-form customer metadata tags.

`--set key=value` merges into the existing metadata — keys you do not name keep their current values. Use `--unset key` to remove one and `--clear-metadata` to drop them all. Values are parsed as JSON when they parse (`42`, `true`, `null`, `{"a":1}`), so metadata can hold numbers, booleans and nested objects, not only strings. When you want a value stored verbatim, use `--set-string`.

`--description ""` and `--git-repo-url ""` clear those fields; omitting the flag leaves them untouched.

The environment is the one your CLI is pointed at; use the global `--environment` flag to target a different one.

`--git-repo-url` is stored on the environment's **project**, not on the environment, because it is what builds the commit and tag links shown for a deployment. Setting it therefore affects every environment in that project, and the command tells you how many before asking to proceed.

Metadata is read, merged and written back, so a concurrent edit made between the read and the write is overwritten. Pass `--dry-run` to see the resulting diff first.

**Flags**

- `--description <text>` (string)
  Set the environment's Markdown description. Pass an empty string to clear it.
- `--set <key=value>` (string[], default `[]`)
  `key=value` metadata entry (repeatable). Merges into the existing metadata, leaving keys you do not name alone. Values parse as JSON when possible (`42`, `true`, `["a"]`), otherwise as strings.
- `--set-string <key=value>` (string[], default `[]`)
  Like `--set`, but never interprets the value as JSON. Use it for values that would otherwise be coerced, such as `--set-string build=007` or `--set-string version=1.10`.
- `--unset <key>` (string[], default `[]`)
  Remove a metadata `key` (repeatable). Removing a key that is not present is not an error.
- `--clear-metadata <clear-metadata>` (bool, default `false`)
  Drop every existing metadata key before applying `--set`. On its own it empties the metadata entirely.
- `--git-repo-url <https://github.com/org/repo>` (string)
  Set the git repository URL used to build commit and tag links for deployments. This is stored on the environment's **project**, so it applies to every environment in that project. Pass an empty string to clear it.
- `--dry-run <dry-run>` (bool, default `false`)
  Print the proposed change without applying it.
- `-y, --yes <yes>` (bool, default `false`)
  Skip the confirmation prompt.

**Example**

```
# Add or overwrite two metadata tags, leaving any others alone.
$ chalk environment update-metadata --set team=fraud --set tier=critical

# Set the description at the same time.
$ chalk environment update-metadata \
    --description "Primary production environment for card fraud scoring." \
    --set oncall=fraud-eng

# Remove a tag, and clear the description.
$ chalk environment update-metadata --unset tier --description ""

# Replace the metadata wholesale.
$ chalk environment update-metadata --clear-metadata --set team=fraud

# Point deployment commit links at a repository (applies to the whole project).
$ chalk environment update-metadata --git-repo-url https://github.com/acme/features

# Preview without applying.
$ chalk environment update-metadata --set team=fraud --dry-run
```

## `chalk environment patch`
source: https://docs.chalk.ai/cli?command=environment_patch

```bash
chalk environment patch
```

Use the `chalk environment patch` command to apply a targeted patch to a single resource group within the current environment's spec config.

Two input modes are supported:

1. Raw patch (kubectl-style): chalk environment patch --resource-group foo   
   --patch-type merge   
   --patch '{"services":{"engine-grpc":{"engine_image_uri_override":"gcr.io/..."}}}'

  `--patch-type` may be:

  - `merge` (default): RFC 7396 JSON merge patch. Fields set to `null` are deleted.
  - `json`: RFC 6902 JSON patch (array of `{op, path, value}` ops).

  Read from stdin with `--patch-file -`.
2. Convenience sugar: chalk environment patch --resource-group foo   
   --service engine-grpc   
   --set engine_image_uri_override=gcr.io/chalk/engine:sha-abc123

  Each `--set key=value` nests under `services.<service>`. Dotted keys (`cpu.requests=500m`) build nested objects. Values are parsed as JSON when possible (`true`, `42`, `"quoted"`), otherwise treated as strings.

The patch targets only the matching resource group inside `spec_config_json`; the rest of the spec config is preserved as-is.

To patch the environment-level `default` resource group (whose fields live at the top level of `spec_config_json` alongside the `resource_groups` array), pass `--resource-group default`. Patches targeting `default` may not modify the `resource_groups` key.

**Flags**

- `--resource-group <default>` (string)
  Name of the resource group to patch in the environment's spec config. Use `default` to patch the environment-level config (the fields that live alongside `resource_groups`).
- `--patch-type <merge>` (string, default `merge`)
  Patch format: `merge` (RFC 7396 JSON merge patch, the default) or `json` (RFC 6902 JSON patch).
- `-p, --patch <{"services":{"engine-grpc":{"engine_image_uri_override":"..."}}}>` (string)
  Patch body as a JSON string. Mutually exclusive with `--patch-file` and the `--service`/`--set` sugar.
- `--patch-file <patch.json>` (string)
  Path to a file containing the patch body (use `-` for stdin). Mutually exclusive with `--patch` and the `--service`/`--set` sugar.
- `--service <engine-grpc>` (string)
  Sugar: scope a set of `--set key=value` entries under `services.<service>` of the resource group. Synthesizes a merge patch.
- `--set <set>` (string[], default `[]`)
  Sugar: `key=value` entry (repeatable) applied under the `--service` block. Values parse as JSON if possible, otherwise as strings. Dotted keys (`a.b.c`) build nested objects.
- `--dry-run <dry-run>` (bool, default `false`)
  Print the proposed change without applying it.
- `-y, --yes <yes>` (bool, default `false`)
  Skip the confirmation prompt.

**Example**

```
# Convenience sugar: set fields on a service inside a resource group.
$ chalk environment patch --resource-group default \
    --service engine-grpc \
    --set engine_image_uri_override=gcr.io/chalk/engine:sha-abc123

# Raw merge patch (RFC 7396).
$ chalk environment patch --resource-group default \
    --patch-type merge \
    --patch '{"services":{"engine-grpc":{"engine_image_uri_override":"gcr.io/chalk/engine:sha-abc123"}}}'

# Preview without applying.
$ chalk environment patch --resource-group default \
    --service engine-grpc --set replicas=3 --dry-run
```

## `chalk environment suspend`
source: https://docs.chalk.ai/cli?command=environment_suspend

```bash
chalk environment suspend
```

Use the `chalk environment suspend` command to suspend an environment.

Suspending an environment will spin down all the environment's cloud resources, including jobs, query servers, and in-cluster databases. This will cause the environment to stop consuming Chalk credits, but will also make the environment unusable for querying until it is resumed.

Suspending an environment will also make certain dashboard features unavailable, such as metrics, datasets, and online/offline query records.

This is a potentially dangerous operation, because it will stop all query traffic to this environment, which may impact production systems. Please use with caution.

**Flags**

- `-f, --force <force>` (bool, default `false`)
  Force suspend/resume without confirmation.

## `chalk environment resume`
source: https://docs.chalk.ai/cli?command=environment_resume

```bash
chalk environment resume
```

Use the `chalk environment resume` command to resume a suspended environment.

Resuming a suspended environment will spin up all the environment's cloud resources, including jobs, query servers, and in-cluster databases. This will cause the environment to start consuming Chalk credits again, and will make the environment available for querying.

It will also re-enable certain dashboard features that are unavailable for suspended environments, such as metrics, datasets, and online/offline query records.

**Flags**

- `-f, --force <force>` (bool, default `false`)
  Force suspend/resume without confirmation.
