Managing project environments
An environment is a set of variables that Cloudera SQL Stream Builder (SSB) substitutes into the properties of tables, data sources, and catalogs. Use environments to run the same project in development, staging, and production with different values.
Environments work like configuration files that adapt a project to a target cluster. For example, you might keep one environment for each of your development, staging, and production clusters, with different hostnames, databases, service URLs, and credentials.
A project can have several environments, but only one is active at a time. You can export an environment to a file and import it into another project or deployment.
Environments belong to the project, but they are not exported to Git with it, and importing a project does not change them. This keeps secrets out of the repository.
Using environment variables
Reference a variable of the active environment as
${ssb.env.[***KEY***]}. You can use variables in
the following places:
- The
WITHproperties ofCREATE TABLEstatements, for example:CREATE TABLE orders (...) WITH ( 'connector' = 'kafka', 'properties.bootstrap.servers' = '${ssb.env.kafka_brokers}', ... ); - The properties of Kafka data sources, such as the bootstrap servers and the truststore location.
- The properties of catalogs, such as the Kudu masters or the URI of a Cloudera Harmony catalog.
You can combine literal text and variables in one value:
'url' = 'https://${ssb.env.connector_host}:${ssb.env.connector_port}'
You can also set a
variable for your session only, with SET_VAR. Session variables are not
saved, and you reference them without the ssb.env prefix. They are displayed on
the User Defined Variables tab of your SSB session.
SET_VAR 'topic_name' = 'orders';
CREATE TABLE orders (...) WITH ('topic' = '${topic_name}', ...);
To remove a session variable, run RESET_VAR 'topic_name';. To remove all
session variables, run RESET_VAR;.
Environment administration
In the list of environments, you can do the following:
- Click the Deactivate icon to stop using the active environment.
- Click the Import icon to import an environment file from your computer.
- Open the More menu of an environment, and click Export to download it as a file, or Delete to remove it. You cannot delete the active environment.
To change an environment, click its name, edit the variables, and click Apply Changes. When you change the active environment, SSB asks you to confirm with Update and Apply.
