Alchemy profiles provide a simple way to manage credentials for cloud providers without juggling multiple .env
files or separate login
CLI commands.
Configure Profile
Section titled “Configure Profile”To create (or update) a profile, run the alchemy configure
command:
alchemy configure
# or select a specific profilealchemy configure --profile prod
After configuring a profile, you can use the alchemy login
command to refresh each provider’s credentials.
# log in to the default profilealchemy login
# log in to a named profilealchemy login --profile prod
Logout
Section titled “Logout”To clear a profile’s credentials, run the alchemy logout
command:
alchemy logout
# log out of a specific profilealchemy logout --profile prod
Select Profile
Section titled “Select Profile”The alchemy deploy
, dev
, run
and destroy
commands all support the --profile
flag to specify which profile to use.
alchemy deploy --profile prod
You can override the profile using environment variables:
ALCHEMY_PROFILE=prod alchemy deploy
Or just a specific provider’s default profile (e.g. Cloudflare):
CLOUDFLARE_PROFILE=prod alchemy deploy
Resources that support profiles can also be configured individually:
import { Worker } from "alchemy/cloudflare";
const worker = await Worker("my-worker", { profile: "prod",});
You can also set the profile globally (for all resources in the App):
await alchemy("my-app", { profile: "prod",})
Configuration and Credential Files
Section titled “Configuration and Credential Files”The profile configuration and credential files are stored in your ~/.alchemy
directory:
# Configuration file (no sensitive data)~/.alchemy/config.json
# Credentials file (sensitive data)~/.alchemy/credentials/default/cloudflare.json
config.json
Section titled “config.json”The alchemy configure
command will create or update the config.json
file with the profile configuration. No sensitive data is stored in this file.
For example, the below config.json
contains two profiles each with a Cloudflare provider configured to use OAuth:
{ "version": 1, "profiles": { // The default profile "default": { "cloudflare": { "method": "oauth", "metadata": { "id": "<account-id>", "name": "<account-name>" }, "scopes": [ "account:read", "user:read", "workers:write" ] } }, // A named profile (e.g. alchemy configure --profile prod) "prod": { "cloudflare": { "method": "api-token", "metadata": { "id": "<account-id>", "name": "<account-name>" } } } }}
{profile}/{provider}.json
Section titled “{profile}/{provider}.json”The alchemy login
command will create or update the credentials/<profile>/<provider>.json
file with the provider’s credentials.
For example, the below credentials/prod/cloudflare.json
contains the OAUth access and refresh tokens for the Cloudflare provider configured in the prod
profile:
{ "type": "oauth", "access": "<access token>", "refresh": "<refresh token>", "expires": 1758577621359}