astro env variable link create

This command is only available on Astro.

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, then recreate it without --value.

Usage

$astro env variable link create

Options

OptionDescriptionPossible Values
--variable-keyThe key of the Workspace variable to link. Provide either this or --variable-id.Any string
--variable-idThe ID of the Workspace variable to link. Provide either this or --variable-key.Any valid variable ID
--deployment-idThe ID of the Deployment to link. Required.Any valid Deployment ID
--valueAn override value to use for the linked Deployment. Only the linked Deployment uses this value. Mutually exclusive with --exclude.Any string
--excludeExclude the Deployment from an auto-linked variable instead of linking it. Mutually exclusive with --value.None
--workspace-idSet the Workspace scope. Defaults to your current Workspace from CLI context.Any valid Workspace ID

Examples

$# 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