www/apps/cloud/app/environments/environment-variables/page.mdx
import { InlineIcon, getOsShortcut, Kbd } from "docs-ui" import { EllipsisHorizontal } from "@medusajs/icons"
export const metadata = {
title: Manage Environment Variables,
}
In this guide, you'll learn how to manage environment variables of long-lived and preview environments in Cloud.
Environment variables are key-value pairs of sensitive information, such as API keys and credentials. Instead of hardcoding these variables in your codebase, you should store them as environment variables.
You can manage an environment's variables in its "Settings" tab. You can manage environment variables for the environment's Medusa backend and storefront (if applicable).
The following environment variable names are reserved by Cloud and you can't use them in your environment:
NODE_ENVEXECUTION_CONTEXTDATABASE_URLREDIS_URLMEDUSA_WORKER_MODEPORTK_SERVICEK_CONFIGURATIONK_REVISIONK_CONTAINER_NAMEK_INTERNAL_POD_NAMEK_INTERNAL_POD_NAMESPACEK_LOCAL_ADDRK_PROTOCOLSESSION_STOREDYNAMO_DB_SESSIONS_TABLEDYNAMO_DB_SESSIONS_HASH_KEYDYNAMO_DB_SESSIONS_PREFIXAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGIONMEDUSA_CLOUD_API_KEYMEDUSA_CLOUD_ENVIRONMENT_HANDLEMEDUSA_CLOUD_EMAILS_ENDPOINTTo add environment variables to an environment:
<Note title="Tip">You can also navigate to an environment's variables from the command palette. Press <Kbd>{getOsShortcut()}</Kbd> + <Kbd>K</Kbd>, select Edit Variables, then choose a project.
</Note>.env format:
.env file format, you can paste them directly into the "Key" field. The environment variables will be pre-filled for you..env file:
.env file that defines your environment variables, click the "Import .env" button to upload the file. The environment variables will be automatically extracted and added to the list.After adding the environment variables, you must redeploy the environment for the changes to take effect.
</Note>To edit an environment variable:
<Note title="Tip">You can also navigate to an environment's variables from the command palette. Press <Kbd>{getOsShortcut()}</Kbd> + <Kbd>K</Kbd>, select Edit Variables, then choose a project.
</Note>After editing the environment variable, you must redeploy the environment for the changes to take effect.
</Note>To delete an environment variable:
<Note title="Tip">You can also navigate to an environment's variables from the command palette. Press <Kbd>{getOsShortcut()}</Kbd> + <Kbd>K</Kbd>, select Edit Variables, then choose a project.
</Note>After deleting the environment variable, you must redeploy the environment for the changes to take effect.
</Note>You can export an environment's variables as a .env file. This is useful for debugging issues that require you to have the same environment variables.
To export an environment's variables:
<Note title="Tip">You can also navigate to an environment's variables from the command palette. Press <Kbd>{getOsShortcut()}</Kbd> + <Kbd>K</Kbd>, select Edit Variables, then choose a project.
</Note>A file download will start with the name env.txt, which contains the environment variables in .env format.
You can rename the file to .env and use it in your local development.