> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# astro env variable update

> Set the value of an Environment Manager environment variable.

<Info>
  This command is only available on Astro.
</Info>

Set the value of an environment variable. By default this command upserts: if the key doesn't exist, the CLI creates it. Pass `--strict` to fail when the key is missing. Use `--from-file` to bulk-upsert variables from a dotenv file.

The platform API doesn't allow toggling the secret flag on an existing variable. To change whether an existing variable is secret, delete it and recreate it.

## Usage

```bash wrap theme={null}
astro env variable update [<id-or-key>]
```

## Options

| Option | Description | Possible Values |
| - | - | - |
| `<id-or-key>` | The ID or key of the variable to update. Omit this argument when you use `--from-file`. | Any valid variable ID or key |
| `-v`,`--value` | The new variable value. If omitted, the CLI reads the value from stdin when piped, or prompts for it with the input hidden. | Any string |
| `-s`,`--secret` | When the variable doesn't exist and the CLI creates it, mark it as secret. This has no effect when updating an existing variable. | None |
| `--strict` | Fail if the variable doesn't exist instead of creating it. | None |
| `--from-file` | Bulk-upsert variables from a dotenv file. Pass `-` to read from stdin. Mutually exclusive with `--value` and the positional `<id-or-key>`. | Any valid file path, or `-` |
| `--auto-link` | Workspace scope only. Automatically link the variable to all Deployments in the Workspace, including future ones. | None |
| `--workspace-id` | Set the Workspace scope. Mutually exclusive with `--deployment-id`. Defaults to your current Workspace from CLI context. | Any valid Workspace ID |
| `--deployment-id` | Set the Deployment scope. Mutually exclusive with `--workspace-id`. | Any valid Deployment ID |

## Examples

```bash wrap theme={null}
# Update a Workspace variable's value
astro env variable update DBT_PROFILES_DIR --workspace-id <workspace-id> --value /etc/profiles

# Bulk-upsert variables from a dotenv file
astro env variable update --workspace-id <workspace-id> --from-file .env

# Fail if the variable doesn't already exist
astro env variable update DBT_PROFILES_DIR --workspace-id <workspace-id> --value /etc/profiles --strict
```

## Related commands

* [`astro env variable create`](/docs/cli/v1.46/astro-env-variable-create)
* [`astro env variable get`](/docs/cli/v1.46/astro-env-variable-get)
* [`astro env variable list`](/docs/cli/v1.46/astro-env-variable-list)
