Environment Variables and Metadata Filesystem

Inside a workspace, information about the sandbox and workspace can be retrieved from special environment variables and the metadata filesystem.

Environment Variables

The following environment variables are made available in workspaces and containers:

NameValueExample
SANDBOX_SYSTEM_URLThe URL to access the WebUI, APIs, etc.https://sandboxes.cloud
SANDBOX_SYSTEM_DNS_SUFFIXThe suffix used for constructing a full subdomain after the system URL.sandboxes.cloud
SANDBOX_SYSTEM_DOMAINThe base domain (aka hostname) of the system URLsandboxes.cloud
SANDBOX_ORG_IDThe id of the org
SANDBOX_ORGThe org nameexample
SANDBOX_TEMPLATEThe name of the template which the sandbox is created fromexample1
SANDBOX_TEMPLATE_FULL_NAMEThe full name of the template including folders (if folder support is enabled), otherwise the same value as SANDBOX_TEMPLATEdemo/example1
SANDBOX_TEMPLATE_FOLDERThe folder name of the template (if folder support is enabled)demo
SANDBOX_IDThe id of the sandbox
SANDBOX_NAMEThe name of the sandboxexample1-dev
SANDBOX_FULL_NAMEThe full name of the sandbox including folders (if folder support is enabled), otherwise the same value as SANDBOX_NAMEwork/example1-dev
SANDBOX_FOLDERThe folder name of the sandbox (if folder support is enabled)work
SANDBOX_REGIONThe region name if the sandbox is in a remote region. Unset if in the main region
SANDBOX_WORKLOADThe name of the current workload, regardless of typedev
SANDBOX_WORKSPACEIf the current workload is a workspace, this is set to the namedev
SANDBOX_CONTAINERIf the current workload is a container, this is set to the namesqlpad
SANDBOX_OWNER_IDThe user ID of the sandbox owner
SANDBOX_OWNERThe name (effectively the email) of the sandbox ownerjack@example.com
SANDBOX_OWNER_EMAILThe email of the sandbox ownerjack@example.com
SANDBOX_OWNER_NAMEThe display name of the sandbox ownerJack Smith
SANDBOX_POOL_IDOnly set to the id of the sandbox pool where the current sandbox is running. Unset once the sandbox is claimed
SANDBOX_APP_DOMAINThe base domain for endpointsexample1-dev-example.sandboxes.run
SANDBOX_ENDPOINT_DNS_SUFFIXThe suffix used for constructing a full endpoint DNS name--example1-dev-example.sandboxes.run

These environment variables are available to all daemons and jobs. As a side effect, changing any of these environment variables will restart daemons, jobs, and all container workloads.

Some *_DNS_SUFFIX environment variables are useful for constructing full DNS names. For example, if the sandbox contains an endpoint named web, its full DNS name can be constructed as: web${SANDBOX_ENDPOINT_DNS_SUFFIX}.

Metadata Filesystem

Part of the above information is also available in the metadata filesystem of workspaces. It can be accessed as files under /run/sandbox/fs/metadata.

FileContent
sandbox.jsonThe basic information about the sandbox
template.jsonThe basic information about the template used to create the sandbox
owner.jsonThe basic information about the sandbox owner
app-domainContains the value of env SANDBOX_APP_DOMAIN
endpoint-dns-suffixContains the value of env SANDBOX_ENDPOINT_DNS_SUFFIX

See Also