cdf build command
to build the necessary artifacts to deploy the modules.
Before you deploy the artifacts, we recommend that you always do a dry-run deployment to verify
that the configurations and deployment perform as expected.
When you’ve verified the configuration, you run the cdf deploy command to deploy the artifacts to the CDF project using the CDF SDK and APIs.
1
Configure access to the CDF project
You must set up authentication for the Cognite Toolkit to access the target CDF Project. Check the
Authentication section for details.
2
Configure modules
To configure the modules to deploy to a CDF project:
-
The
cdf modules initcommand will usually have created aconfig.<env>.yamlfile for each of your environnments.You need one config.<env>.yaml file for each CDF project you deploy to. For example, if you haveprod,staging, anddevprojects/environments, you need config.prod.yaml, config.staging.yaml, and config.dev.yaml configuration files. -
Open the configuration file, and edit the
projectproperty to match the name of your CDF project (line 3 in this example):showLineNumbers -
In the
selectedproperty, list the modules you want to deploy (lines 6-7 above). You can list any of the modules in the modules sub-directory. -
Update the variables in the
variablessection to match the CDF project you’re deploying to, for example, to change the name of your default location.
- Save the configuration file.
3
Build deployment artifacts
To build the artifacts to deploy for the modules you have configured:
-
In a terminal, run these commands:
The
--env=<env>parameter specifies which configuration file to use, in this example config.dev.yaml.
4
Deploy to the CDF project
To deploy the configured artifacts to your CDF project:To also remove and redeploy the data, add the To delete everything in your project that is managed by your configurations:
-
In a terminal, run these commands to do a dry-run of the deployment:
-
Inspect the output from the dry run and verify that the configurations and deployment perform as expected.
-
Run this command to deploy the artifacts to your CDF project:
Clean up configurations and data
To deploy from a clean state, you can remove configurations and data before you deploy. This is typically not necessary for regular deployments, but can be useful, for example, for resources that rejects updates, and you want to force a clean deployment.One use case is data modeling views. Views can reject an update as the change might require a version bump. If you want to delete and recreate the view, which is common in development, you can use the--drop option to
remove the view before deploying it again.Remove and redeploy configurations and data
To remove and redeploy configurations, but keep the data, run this command:--drop-data option: