cdf build while they develop configuration. Cognite Toolkit administrators use it in CI/CD to stop a deploy when the build reports errors.
Authenticate first and keep a .env file in the directory where you run the Cognite Toolkit. See Authenticating with the Cognite Toolkit.
A small set of files can live directly in build/, which is what Deploying configurations does. Larger projects usually have more than one CDF project, small differences between those projects, and resources that depend on each other. cdf build organizes the YAML files, checks those dependencies, and substitutes variables so the same modules can target each project.
1
Create a module
A module is a folder of YAML files that you deploy together. One module can hold the configuration for ingesting data from one source. In this article, you create a small data model.Create The directory looks like this:The directory name
modules/my_module/data_modeling/my.View.yaml with the following content:my.View.yaml
data_modeling and the suffix .View.yaml tell the Cognite Toolkit which resource type the YAML file defines. The resource library lists every supported resource.2
Build the module
Run the following command to build the module:You did not specify which module to build, so the Cognite Toolkit prompts you to select one. Skip the prompt
by naming the module: The Cognite Toolkit loads the module and builds it. In this example it loads one module and one resource file.
cdf build --modules my_module.Select module to build
3
Review the build results
The Cognite Toolkit then validates agents, data modeling, dependencies, functions, and Cognite InField configuration.If the build finds insights, the Cognite Toolkit prints them:The build reports three insights for the view. You fix them in the Fix insights found in the build step. In most terminals,
Insights/issues
modules/my_module/data_modeling/my.View.yaml:10:34 is a link that opens the file at the line and column where the insight was found.The summary reports three errors and says Do not proceed to deploy. The view depends on a space and a container that are missing, so the deployment would fail.4
Fix insights found in the build
Fix the insights from the Review the build results step by creating the missing space and container. Create
and The directory looks like this:
modules/my_module/data_modeling/my.Space.yaml with the following content:my.Space.yaml
modules/my_module/data_modeling/my.Container.yaml with the following content:my.Container.yaml
5
Rebuild the module
Run the following command to rebuild the module:The build and validation match the Review the build results step. This time there are no insights, and the summary says Ready to deploy.Inspect the
build/ directory. The Cognite Toolkit has created a subdirectory for each resource type and placed the
built YAML files in the corresponding subdirectory. The built YAML files match the source YAML files.6
Create config.dev.yaml
The For more information about the In the three YAML files, replace the hardcoded
space property in the space, container, and view is hardcoded to my_space in all three YAML files.
That is easy to get wrong when the identifier changes, or when dev and prod use different spaces. Create a config.dev.yaml
file:config.dev.yaml
config.dev.yaml file, see Configuration file.The directory structure is now:my_space with {{ space }}. For example, my.View.yaml:my.View.yaml
7
Rebuild the module with config.dev.yaml
Run the following command to rebuild the module with the The build and validation plan match the Rebuild the module step. In
config.dev.yaml file:build/, the YAML files have space set to my_space.This command omits --modules. config.dev.yaml already lists the modules to build in environment.selected. If you pass --modules, that flag overrides environment.selected.Next steps
Deploy thebuild/ directory. See Deploying configurations.
For every field in config.[env].yaml, see Configuration file.