> ## 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 deployment variable update

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

For a given Deployment on Astro, use `astro deployment variable update` to update the value of an existing environment variable with the Astro CLI. To do so, you can either:

* Manually enter a new `key=value` pair for an existing key directly in the command.
* Modify the value of one or more environment variables in a `.env` file and load that file with `--load`.

This command is functionally identical to editing and saving the value of an existing environment variable in the Astro UI. For more information on environment variables, see [Set environment variables on Astro](/docs/astro/manage-env-vars).

## Usage

```sh wrap theme={null}
astro deployment variable update
```

<Tip>
  This command is recommended for automated workflows. To run this command in an automated process such as a [CI/CD pipeline](/docs/astro/set-up-ci-cd), you can generate an API token, then specify the `ASTRO_API_TOKEN` environment variable in the system running the Astro CLI:

  ```bash wrap theme={null}
  export ASTRO_API_TOKEN=<your-token>
  ```

  See [Organization](/docs/astro/organization-api-tokens), [Workspace](/docs/astro/workspace-api-tokens), and [Deployment](/docs/astro/deployment-api-tokens) API token documentation for more details about ways to use API tokens.
</Tip>

## Options

| Option                 | Description                                                                                                                                                                                                                                                                                             | Possible Values           |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `-d`,`--deployment-id` | The ID of the Deployment whose environment variable(s) you want to update.                                                                                                                                                                                                                              | Any valid Deployment ID   |
| `--deployment-name`    | The name of the Deployment whose environment variable(s) you want to update. Use as an alternative to `<deployment-id>`.                                                                                                                                                                                | Any valid Deployment name |
| `-e`,`--env`           | The path to a file that contains a list of environment variables. If a filepath isn't specified, this looks for a `.env` file in your current directory. If `.env` doesn't exist, this flag will create it for you                                                                                      | Any valid filepath        |
| `-l`,`--load`          | Export updated environment variables from your Astro project's `.env` file to the Deployment. This is an alternative to updating an environment variable by manually specifying `--key` and `--value`. By default, this flag updates all environment variables based on the file specified with `--env` | \`\`                      |
| `-s`,`--secret`        | Set the value of the updated environment variable as secret                                                                                                                                                                                                                                             | \`\`                      |
| `-w`,`--workspace-id`  | Update an environment variable for a Deployment that is not in your current Workspace. If this is not specified, your current Workspace is assumed                                                                                                                                                      | Any valid Workspace ID    |

## Examples

```sh wrap theme={null}
# Update an existing environment variable and set as secret
$ astro deployment variable update --deployment-id cl03oiq7d80402nwn7fsl3dmv AIRFLOW__SECRETS__BACKEND_KWARGS=<my-new-secret-value> --secret

# Update multiple environment variables for a Deployment at once by loading them from a .env file
$ astro deployment variable update --deployment-id cl03oiq7d80402nwn7fsl3dmv --load --env .env.dev
```

## Related commands

* [`astro deployment variable create`](/docs/cli/v1.40/astro-deployment-variable-create)
* [`astro deployment variable list`](/docs/cli/v1.40/astro-deployment-variable-list)
