An environment defines how traffic will be served through Edgio. Each environment consists of:
- Hostnames: A hostname identifies a domain (e.g.,
cdn.example.com
) through which your site will be served. - Origins: An origin configuration defines how our service will communicate with your web servers.
- Rules: A rule determines how requests for a specific environment will be processed.
- Core Web Vitals: Review and analyze performance metrics collected through the measurement of actual Chrome users.
- Caching: By default, deploying to an environment also clears that environment’s cached content. You may manually purge content from the Caching page, the Edgio CLI, or our REST API.
- Environment Variables: An environment variable is a placeholder for sensitive information (e.g., API keys and passwords) that should not be checked into source control.
- Traffic (Analytics): Contains real-time statistics for this environment’s traffic. You may also view a breakdown of traffic by specific routes.
- Real-Time Log Delivery: Delivers log data in near real-time to a variety of destinations.
- User Activity: Contains an audit trail of changes to this environment (e.g., changes to your configuration and deployments).
- Edge Insights: Gain historical and near real-time insights into threat profiles, performance, and CDN usage.
Key information:
-
By default, all new properties contain an environment called
production
. Theproduction
environment cannot be renamed or deleted. -
You may create additional environments for your property.
Set up your environments to match your software development workflow.
For example, you could create a development, testing, and staging environment to allow your team members to collaborate at every stage of your software development life cycle.
-
Applying changes to an environment requires a deployment.
-
Deployments to your environments are versioned. This allows you to quickly roll back your environment’s configuration to a known working version.
Creating an Environment
Perform the following steps to create an environment:
-
Load the Environments page.
- From the Edgio Developer console, select the desired private or team space.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
-
Click + New Environment.
-
In the Name option, specify a name for this environment. This name may consist of lowercase characters, numbers, dashes (
-
), and underscores (_
). -
Optional. Copy environment variables, A/B testing configuration, and notes from another environment by selecting it from the
Copy settings from environment
option. -
Determine deployment permissions through the Allow all team members to deploy to this environment option.
- Mark this option to allow all team members to deploy to this environment.
- Clear this option to restrict deployment to admins and the deploy token.
-
Click Create.
Environment Variables
Environment variables allow you to control certain facets of your application outside of its code. There are two types of Edgio environment variables:
-
System-defined: Edgio automatically defines the following variables within each environment:
NODE_ENV
: By default, this variable is set toproduction
. Override this default value by creating a variable calledNODE_ENV
and setting it to the desired value.EDGIO_ENVIRONMENT_NAME
: This read-only variable is set during deployment to the name of the environment (e.g.,production
) being deployed.
-
Custom: Create custom variables for sensitive information (e.g., API keys and passwords) that should be excluded from source control.
Managing Environment Variables
You may create, modify, and delete environment variables from the Edgio Developer console.
Key information:
- Applying environment variable changes requires a deployment.
- Once an environment variable has been marked as secret, you cannot unset the Keep this value a secret option for that environment variable.
- The value assigned to a secret environment variable is masked using asterisks and it is never revealed. However, you may set it to a different value.
To create an environment variable
-
Load the Environment Variables page.
- From the Edgio Developer console, select the desired private or team space.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
- From the left-hand pane, select Environment Variables.
-
Click + Add an Environment Variable.
-
In the Key option, type a name for this environment variable.
-
In the Value option, assign a value to this environment variable.
-
If this environment variable contains sensitive information that should not be revealed to other team members, then you should mark the Keep this value a secret option. Otherwise, this option should be cleared.
-
Click Add variable.
To modify an environment variable
-
Load the Environment Variables page.
- From the Edgio Developer console, select the desired private or team space.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
- From the left-hand pane, select Environment Variables.
-
Click on the desired environment variable.
-
Modify the environment variable’s name, value, or both.
-
Click Apply.
To delete an environment variable
-
Load the Environment Variables page.
- From the Edgio Developer console, select the desired private or team space.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
- From the left-hand pane, select Environment Variables.
-
Click on the icon next to the desired environment variable.
-
When prompted, click Remove Variable to confirm the permenant deletion of that environment variable.
Accessing Environment Variables
Build Time
When you deploy to an environment using a deploy token, for example by running edgio deploy my-team --environment=production --token=(my token)
option, all environment variables are pulled down from the Edgio Developer console and applied to process.env
so they can be accessed at build time. This allows you to store all of your build and runtime secrets in a single place, the Edgio Developer console, rather than storing some in your CI system’s secret manager.
Runtime
The variables you configure on an environment can be accessed in your code using process.env
. A common use case is to configure
different backend host names in edgio.config.js
based on the environment. Here is an example where the origin backend is determined
by a HOST
environment variable.
1// edgio.config.js2const defaultHostname = 'origin.my-site.com'34module.exports = {5 backends: {6 origin: {7 domainOrIp: process.env.HOST || defaultHostname, // Falling back to defaultHostname is needed during the initial8 hostHeader: process.env.HOST || defaultHostname, // deployment of your site, when an environment is not yet configured.9 },10 },11}
Note that your edgio.config.js
file is loaded during deployment to configure the edge for your environment. The first time you
deploy your site, there won’t be any environment variables defined, so you need to include defaults in edgio.config.js
as
shown in the example above.
dotenv
To configure secrets during local development, we recommend using dotenv.
If you would like to reference environment variables read from .env
in edgio.config.js
, add the following at the top
of edgio.config.js
:
1// edgio.config.js2require('dotenv').config()
Deleting an Environment
Perform the following steps to permanently delete an environment:
-
Load the Environments page.
- From the Edgio Developer console, select the desired private or team space.
- Select the desired property.
- From the left-hand pane, select the desired environment from under the Environments section.
-
Click the icon next to the desired environment and then click Delete.
-
When prompted, click Remove Environment to confirm the permenant deletion of that environment.
The production
environment cannot be deleted.