> ## 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 link create

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

Attach a Workspace-scoped environment variable to a specific Deployment. When you pass `--value`, that value overrides the Workspace default for the linked Deployment only. The Workspace value and other Deployments are unaffected. Pass `--exclude` to opt a Deployment out of a variable that automatically links to every Deployment in the Workspace.

This command is idempotent. If the link doesn't exist, the CLI creates it. If the link already exists, the CLI replaces the override when you pass `--value`. To remove an existing override, delete the link with [`astro env variable link delete`](/docs/cli/v1.43/astro-env-variable-link-delete), then recreate it without `--value`.

## Usage

```bash wrap theme={null}
astro env variable link create
```

## Options

| Option            | Description                                                                                                                          | Possible Values         |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- |
| `--variable-key`  | The key of the Workspace variable to link. Provide either this or `--variable-id`.                                                   | Any string              |
| `--variable-id`   | The ID of the Workspace variable to link. Provide either this or `--variable-key`.                                                   | Any valid variable ID   |
| `--deployment-id` | The ID of the Deployment to link. Required.                                                                                          | Any valid Deployment ID |
| `--value`         | An override value to use for the linked Deployment. Only the linked Deployment uses this value. Mutually exclusive with `--exclude`. | Any string              |
| `--exclude`       | Exclude the Deployment from an auto-linked variable instead of linking it. Mutually exclusive with `--value`.                        | None                    |
| `--workspace-id`  | Set the Workspace scope. Defaults to your current Workspace from CLI context.                                                        | Any valid Workspace ID  |

## Examples

```bash wrap theme={null}
# Link a Workspace variable to a Deployment
astro env variable link create --variable-key DATABASE_URL --workspace-id <workspace-id> --deployment-id <deployment-id>

# Link with a per-Deployment override value
astro env variable link create --variable-key DATABASE_URL --workspace-id <workspace-id> --deployment-id <deployment-id> --value "postgres://prod-host:5432/app"

# Exclude a Deployment from an auto-linked variable
astro env variable link create --variable-key LOG_LEVEL --workspace-id <workspace-id> --deployment-id <deployment-id> --exclude
```

## Related commands

* [`astro env variable link list`](/docs/cli/v1.43/astro-env-variable-link-list)
* [`astro env variable link delete`](/docs/cli/v1.43/astro-env-variable-link-delete)
* [`astro env variable create`](/docs/cli/v1.43/astro-env-variable-create)
