Environment variables
You can use the CLI to set environment variables for your Actors.
For the list of the system variables that Apify provides, see Environment variables.
Custom environment variables
To pass additional configuration to your Actor, define custom environment variables.
Define in .actor/actor.json
To set custom variables, add them to the environmentVariables object in .actor/actor.json and push the Actor to Apify:
{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest",
"environmentVariables": {
"MYSQL_USER": "my_username",
"MYSQL_PASSWORD": "@mySecretPassword"
}
}
Variables defined in .actor/actor.json override the ones defined in Apify Console.
Define in Apify Console
To set custom variables in Apify Console:
- Log in to Apify Console.
- In the left-side panel, go to Development > My Actors.
- From the table, select the Actor you want to configure.
- Go to the Source tab > Code.
- Expand the Environment variables section.
Once done, delete environmentVariables from .actor/actor.json. Variables defined in that file override the ones defined in Apify Console.
{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest"
}
Define secrets
You can use the CLI to manage secrets environment variables:
-
To add a secret, use the
apify secrets addcommand. All secrets are stored in the~/.apifydirectory.apify secrets add mySecretPassword pwd1234 -
To reference the secret in
.actor/actor.json, use the@prefix:{"actorSpecification": 1,"name": "dataset-to-mysql",..."environmentVariables": {"MYSQL_PASSWORD": "@mySecretPassword"},...}