config.[env].yaml adjacent to the modules/ directory.
The config.[env].yaml file configures the modules for a specific environment. It’s in YAML format in the same directory as the modules/ directory. You’ll likely have at least one config.[env].yaml for each CDF project in your organization.
Example config.[env].yaml file
The environment section
The environment section specifies the configuration of a CDF project.
-
name(string): a descriptive name of the environment. The Cognite Toolkit doesn’t use the string. -
project(string): the name of the CDF project. -
validation-type(string): the type of environment, for example,dev,test,staging,qa, orprod. The toolkit strictly validates all environments exceptdev. For instance, if the environment variableCDF_PROJECTdoesn’t match theprojectvalue, the toolkit throws an error in all environments exceptdev. -
selected(list): a list of modules to include in the configuration. You can override the list using the--modules/-mflag in thebuildcommand. An entry in the list can be either a module name, for example,cdf_ingestion, or a path. If it’s a path, it must be relative to the organization directory. If you specify a path, all modules in subdirectories are included. Usingmodules/as an entry will include all modules in themodules/directory and all subdirectories.
The variables section
The variables section contains variables used by the cdf build command.
You can use variables to define values used in multiple places in the configuration. For example, when creating a data model, it’s helpful to specify the space as a variable since it’s also referred to in containers, views, nodes, and data models. If the space name changes, you only need to update it in one place.
You can also use variables to define values that differ depending on the environment. For example, when you set up authentication, you can have a variable for sourceId that differs in dev and prod CDF projects.
The toolkit uses the variables when you create module templates with either cdf modules init or cdf modules add to show which values must be filled in by the user.
Specifying variables
Variables are organized as key-value pairs. This example has a variable namedspace with the value my_space;
space variable, you can reference it like this:
cdf build, the toolkit replaces {{ space }} with my_space in the data model configuration,
and puts the results in the build/ directory.
Variables structure
You can organize thevariables section to match the module directory structure, for example, if you
have variables that are only used by a single module, and other variables that are used by multiple
modules.
For example, you can have this module directory structure:
config.[env].yaml file:
space, sourceId for cdf_ingestion, plus sourceId for cdf_search.
The space variable is used by all modules, cdf_ingestion and cdf_search in this example.
The sourceId for cdf_ingestion is used only by the cdf_ingestion module, and the sourceId for cdf_search is used only by the cdf_search module.