Expected location:Documentation Index
Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
Use this file to discover all available pages before exploring further.
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.
Module repeat
Available from Cognite Toolkit v0.8.0 Module repeat lets you deploy the same module multiple times with different variable values. This is useful when you have multiple locations, sites, or tenants that should all have the same resources deployed with different configurations. To use module repeat, provide a list of dictionaries as the variable value for a module in theconfig.[env].yaml file. Each dictionary in the list represents one iteration of the module, and the Toolkit builds and deploys the module once for each entry.
Example
Given a moduleto_repeat with a data set template:
location.DataSet.yaml file uses a template variable:
location.DataSet.yaml
config.dev.yaml file, define a list of variable sets under the module key:
config.dev.yaml
cdf build, the Toolkit creates two copies of each resource in the module, one for each entry in the list:
1.location.DataSet.yaml (built)
2.location.DataSet.yaml (built)
Multiple variables per iteration
Each dictionary in the list can contain multiple variables:config.dev.yaml
Shared variables
Variables defined at a parent level are shared across all iterations. For example, if you have a sharedowner variable:
config.dev.yaml
to_repeat can reference {{ owner }} in addition to {{ location }}.