Setting the environment for a project
Environments are sets of user-defined variables that can be substituted into templates in your SSB resources. Environments are like configuration files for your projects that adapt it to be used in a specific environment. They enable you to keep the common resources and logic of a project in a central repository and reuse it across different environments, different clusters.
For example, you might have a development, staging and production environment, each containing different clusters, databases, service URLs and authentication methods. Projects and environments allow you to write the logic and create the resources once, and use template placeholders for values that need to be replaced with the environment specific parameters.
To each project, you can create multiple environments, but only one can be active at a time for a project. Environments can be exported to files, and can be imported again to be used for another project, or on another cluster.
While environments are applied to a given project, they are not part of the project. They are not synchronized to Git when exporting or importing the project. This separation is what allows the storing of environment-specific values, or configurations that you do not want to expose to the Git repository.
- As values in the properties section of a
CREATE TABLE
statement as shown in the following example:CREATE TABLE (...) WITH ('key1'='${ssb.env.yourVariable}')
- In the properties of a Kafka data source, for example bootstrap servers, truststore location
- In the values of Catalog properties, for example Schema Registry URL, Kudu masters, Custom Catalog
${ssb.env.yourVariable}
. You can use multiple substitutions
or combine literals and variable substitutions in the same value string as shown in the
following example:
'some-connector-url' = 'https://${ssb.env.connector-host}:${ssb.env.connector-port}'
SET_VAR 'x' = 'y';
syntax in your queries. These do not become part of the
environment and are not persisted, but live only in the current SQL session. They can be used
for substitutions like environment variables, but without the ssb.env
prefix as
shown in the following
example:SET_VAR 'yourVariable' = 'someValue';
CREATE TABLE (...) WITH ('key1'='${yourVariable}'))
You can reset a variable with the RESET_VAR 'x';
command.