astro env variable export

This command is only available on Astro.

Export the environment variables for a scope as KEY=VALUE lines suitable for a .env file. The output round-trips with the --from-file flag on astro env variable create and astro env variable update, so you can promote variables between Workspaces or pull them into a local Astro project.

By default, the CLI masks secret values. Pass --include-secrets to include them, subject to an Organization policy that allows it. When you use --include-secrets, the CLI prints a sensitive-data warning to stderr so the warning never lands in the exported file.

Usage

$astro env variable export

Options

OptionDescriptionPossible Values
--outputWrite the output to a file. Use - for stdout. Defaults to -.Any valid file path, or -
--include-secretsSurface secret values in the export. Requires an Organization policy that allows it.None
--workspace-idSet the Workspace scope. Mutually exclusive with --deployment-id. Defaults to your current Workspace from CLI context.Any valid Workspace ID
--deployment-idSet the Deployment scope. Mutually exclusive with --workspace-id.Any valid Deployment ID

Examples

$# Export Workspace variables to a local .env file
$astro env variable export --workspace-id <workspace-id> > .env
$
$# Include secret values in the export
$astro env variable export --workspace-id <workspace-id> --include-secrets > .env
$
$# Promote variables from one Workspace to another
$astro env variable export --workspace-id <dev-workspace-id> | \
> astro env variable update --workspace-id <prod-workspace-id> --from-file -