Skip to main content

Configuration

Connecting to a data source needs two kinds of input: connection details (host, database, catalog, …), which live in the contract's servers block, and credentials and connection options (usernames, passwords, tokens, timeouts, …), which are configuration. Every configuration option has a canonical name, its environment variable, such as DATACONTRACT_SNOWFLAKE_USERNAME. The data source pages list the options each source supports.

There are five ways to provide configuration. All of them address options by the same names, and all of them end up in the same place: a Config object that is passed through to the connection.

Environment variables

The default, and the right choice for CI/CD:

export DATACONTRACT_SNOWFLAKE_USERNAME=svc_test
export DATACONTRACT_SNOWFLAKE_PASSWORD=...
datacontract test datacontract.yaml

Environment variables work in every context: CLI, Python library, and API server.

.env file

The CLI loads a .env file from the current working directory, or the nearest parent directory containing one. Values from .env fill in missing environment variables; variables that are already set take precedence.

# .env
DATACONTRACT_POSTGRES_USERNAME=postgres
DATACONTRACT_POSTGRES_PASSWORD=postgres

The .env values are exported into the process environment, so they also reach tools that read the environment directly, such as boto3 (AWS_PROFILE), the Databricks SDK, and Snowflake's SNOWFLAKE_HOME.

Config file (YAML)

A YAML config file groups options in sections per data source. Pass it with the global --config-file option, or place it at one of the default locations: ./datacontract-config.yaml or ~/.datacontract/config.yaml.

# datacontract-config.yaml
snowflake:
username: svc_test
password: ${SNOWFLAKE_PASSWORD}
role: TESTER
login_timeout: 30
max_errors: 10
datacontract --config-file datacontract-config.yaml test datacontract.yaml

Section and key join to form the option name (snowflake.username is DATACONTRACT_SNOWFLAKE_USERNAME). ${VAR} references resolve from the environment when the file is loaded, so the file can be committed without holding secrets; add it to .gitignore if it contains literal credentials. Unknown option names fail with an error naming the key, so typos surface immediately.

In the Python library, load the same file with Config.from_yaml("datacontract-config.yaml").

Python library

Pass configuration programmatically via the config argument, without touching the process environment:

from datacontract import Config
from datacontract.data_contract import DataContract

run = DataContract(
data_contract_file="datacontract.yaml",
server="production",
config=Config(
snowflake_username="svc_test",
snowflake_password=get_secret("snowflake"),
snowflake_role="TESTER",
),
).test()

The Config class declares every option as a typed field. Field names match the environment variable names (snowflake_username for DATACONTRACT_SNOWFLAKE_USERNAME), unknown keyword arguments raise immediately, and secrets are held as SecretStr so they stay out of logs and reprs. A plain dict keyed by the environment variable names is accepted as well. DataContract.import_from_source() takes the same argument. See Python Library for details.

Because the config object is passed explicitly through the connection layer, concurrent operations with different credentials in one process do not interfere.

API server

The API server reads its configuration from environment variables set before startup. In addition, POST /test accepts per-request credentials via datacontract-* headers, matched case-insensitively and mapped to the option names:

curl -X POST https://datacontract.example.com/test \
-H "Content-Type: application/yaml" \
-H "datacontract-snowflake-username: svc_test" \
-H "datacontract-snowflake-password: $SNOWFLAKE_PASSWORD" \
--data-binary @datacontract.yaml

Header values apply to that request only, so one server can test contracts for different tenants without sharing credentials through the process environment. Unknown option names are rejected with a 400.

All options

Every option, by its environment variable name and the matching Config field. The data source pages explain how each source uses them. ${VAR}-style config file keys drop the DATACONTRACT_ prefix and the section name (snowflake.username for DATACONTRACT_SNOWFLAKE_USERNAME); API headers are the environment variable name in lowercase with dashes (datacontract-snowflake-username).

Entropy Data (publishing, remote contracts)

Environment variableConfig fieldTypeNotes
ENTROPY_DATA_API_KEYentropy_data_api_keystring (secret)
ENTROPY_DATA_HOSTentropy_data_hoststring
DATAMESH_MANAGER_API_KEYdatamesh_manager_api_keystring (secret)Deprecated, use ENTROPY_DATA_API_KEY
DATAMESH_MANAGER_HOSTdatamesh_manager_hoststringDeprecated, use ENTROPY_DATA_HOST
DATACONTRACT_MANAGER_API_KEYdatacontract_manager_api_keystring (secret)Deprecated, use ENTROPY_DATA_API_KEY
DATACONTRACT_MANAGER_HOSTdatacontract_manager_hoststringDeprecated, use ENTROPY_DATA_HOST

General

Environment variableConfig fieldTypeNotes
DATACONTRACT_API_HEADER_AUTHORIZATIONapi_header_authorizationstring (secret)
DATACONTRACT_MAX_ERRORSmax_errorsinteger

Athena

Environment variableConfig fieldTypeNotes
DATACONTRACT_ATHENA_CATALOGathena_catalogstringOverrides catalog from the contract's servers block
DATACONTRACT_ATHENA_SCHEMAathena_schemastringOverrides schema from the contract's servers block
DATACONTRACT_ATHENA_STAGING_DIRathena_staging_dirstringOverrides stagingDir from the contract's servers block

Azure

Environment variableConfig fieldTypeNotes
DATACONTRACT_AZURE_CONNECTION_STRINGazure_connection_stringstring (secret)
DATACONTRACT_AZURE_STORAGE_ACCOUNT_KEYazure_storage_account_keystring (secret)
DATACONTRACT_AZURE_TENANT_IDazure_tenant_idstring
DATACONTRACT_AZURE_CLIENT_IDazure_client_idstring
DATACONTRACT_AZURE_CLIENT_SECRETazure_client_secretstring (secret)

BigQuery

Environment variableConfig fieldTypeNotes
DATACONTRACT_BIGQUERY_ACCOUNT_INFO_JSON_PATHbigquery_account_info_json_pathstring
DATACONTRACT_BIGQUERY_BILLING_PROJECTbigquery_billing_projectstring
DATACONTRACT_BIGQUERY_IMPERSONATION_ACCOUNTbigquery_impersonation_accountstring
DATACONTRACT_BIGQUERY_PROJECTbigquery_projectstringOverrides project from the contract's servers block
DATACONTRACT_BIGQUERY_DATASETbigquery_datasetstringOverrides dataset from the contract's servers block

Databricks

Environment variableConfig fieldTypeNotes
DATACONTRACT_DATABRICKS_SERVER_HOSTNAMEdatabricks_server_hostnamestringOverrides host from the contract's servers block
DATACONTRACT_DATABRICKS_HTTP_PATHdatabricks_http_pathstring
DATACONTRACT_DATABRICKS_TOKENdatabricks_tokenstring (secret)
DATACONTRACT_DATABRICKS_CLIENT_IDdatabricks_client_idstring
DATACONTRACT_DATABRICKS_CLIENT_SECRETdatabricks_client_secretstring (secret)
DATACONTRACT_DATABRICKS_PROFILEdatabricks_profilestring
DATACONTRACT_DATABRICKS_AUTH_TYPEdatabricks_auth_typestring
DATACONTRACT_DATABRICKS_CATALOGdatabricks_catalogstringOverrides catalog from the contract's servers block
DATACONTRACT_DATABRICKS_SCHEMAdatabricks_schemastringOverrides schema from the contract's servers block

GCS

Environment variableConfig fieldTypeNotes
DATACONTRACT_GCS_KEY_IDgcs_key_idstring
DATACONTRACT_GCS_SECRETgcs_secretstring (secret)

Impala

Environment variableConfig fieldTypeNotes
DATACONTRACT_IMPALA_USERNAMEimpala_usernamestring
DATACONTRACT_IMPALA_PASSWORDimpala_passwordstring (secret)
DATACONTRACT_IMPALA_AUTH_MECHANISMimpala_auth_mechanismstring
DATACONTRACT_IMPALA_HTTP_PATHimpala_http_pathstring
DATACONTRACT_IMPALA_USE_SSLimpala_use_sslboolean
DATACONTRACT_IMPALA_USE_HTTP_TRANSPORTimpala_use_http_transportboolean
DATACONTRACT_IMPALA_HOSTimpala_hoststringOverrides host from the contract's servers block
DATACONTRACT_IMPALA_PORTimpala_portintegerOverrides port from the contract's servers block
DATACONTRACT_IMPALA_DATABASEimpala_databasestringOverrides database from the contract's servers block

Kafka

Environment variableConfig fieldTypeNotes
DATACONTRACT_KAFKA_SASL_USERNAMEkafka_sasl_usernamestring
DATACONTRACT_KAFKA_SASL_PASSWORDkafka_sasl_passwordstring (secret)
DATACONTRACT_KAFKA_SASL_MECHANISMkafka_sasl_mechanismstring
DATACONTRACT_KAFKA_SCHEMA_REGISTRY_URLkafka_schema_registry_urlstring
DATACONTRACT_KAFKA_SCHEMA_REGISTRY_USERNAMEkafka_schema_registry_usernamestring
DATACONTRACT_KAFKA_SCHEMA_REGISTRY_PASSWORDkafka_schema_registry_passwordstring (secret)

MySQL

Environment variableConfig fieldTypeNotes
DATACONTRACT_MYSQL_USERNAMEmysql_usernamestring
DATACONTRACT_MYSQL_PASSWORDmysql_passwordstring (secret)
DATACONTRACT_MYSQL_HOSTmysql_hoststringOverrides host from the contract's servers block
DATACONTRACT_MYSQL_PORTmysql_portintegerOverrides port from the contract's servers block
DATACONTRACT_MYSQL_DATABASEmysql_databasestringOverrides database from the contract's servers block

Oracle

Environment variableConfig fieldTypeNotes
DATACONTRACT_ORACLE_USERNAMEoracle_usernamestring
DATACONTRACT_ORACLE_PASSWORDoracle_passwordstring (secret)
DATACONTRACT_ORACLE_CLIENT_DIRoracle_client_dirstring
DATACONTRACT_ORACLE_HOSToracle_hoststringOverrides host from the contract's servers block
DATACONTRACT_ORACLE_PORToracle_portintegerOverrides port from the contract's servers block
DATACONTRACT_ORACLE_SERVICE_NAMEoracle_service_namestringOverrides serviceName from the contract's servers block

Postgres

Environment variableConfig fieldTypeNotes
DATACONTRACT_POSTGRES_USERNAMEpostgres_usernamestring
DATACONTRACT_POSTGRES_PASSWORDpostgres_passwordstring (secret)
DATACONTRACT_POSTGRES_HOSTpostgres_hoststringOverrides host from the contract's servers block
DATACONTRACT_POSTGRES_PORTpostgres_portintegerOverrides port from the contract's servers block
DATACONTRACT_POSTGRES_DATABASEpostgres_databasestringOverrides database from the contract's servers block
DATACONTRACT_POSTGRES_SCHEMApostgres_schemastringOverrides schema from the contract's servers block

Redshift

Environment variableConfig fieldTypeNotes
DATACONTRACT_REDSHIFT_AUTHENTICATIONredshift_authenticationstring
DATACONTRACT_REDSHIFT_USERNAMEredshift_usernamestring
DATACONTRACT_REDSHIFT_PASSWORDredshift_passwordstring (secret)
DATACONTRACT_REDSHIFT_SSLMODEredshift_sslmodestring
DATACONTRACT_REDSHIFT_DB_USERredshift_db_userstring
DATACONTRACT_REDSHIFT_DB_GROUPSredshift_db_groupsstring
DATACONTRACT_REDSHIFT_AUTO_CREATEredshift_auto_createboolean
DATACONTRACT_REDSHIFT_WORKGROUPredshift_workgroupstring
DATACONTRACT_REDSHIFT_CLUSTER_IDENTIFIERredshift_cluster_identifierstring
DATACONTRACT_REDSHIFT_REGIONredshift_regionstring
DATACONTRACT_REDSHIFT_DURATION_SECONDSredshift_duration_secondsinteger
DATACONTRACT_REDSHIFT_HOSTredshift_hoststringOverrides host from the contract's servers block
DATACONTRACT_REDSHIFT_PORTredshift_portintegerOverrides port from the contract's servers block
DATACONTRACT_REDSHIFT_DATABASEredshift_databasestringOverrides database from the contract's servers block
DATACONTRACT_REDSHIFT_SCHEMAredshift_schemastringOverrides schema from the contract's servers block

S3 / AWS (also Athena, Redshift IAM, Glue)

Environment variableConfig fieldTypeNotes
DATACONTRACT_S3_ACCESS_KEY_IDs3_access_key_idstring
DATACONTRACT_S3_SECRET_ACCESS_KEYs3_secret_access_keystring (secret)
DATACONTRACT_S3_SESSION_TOKENs3_session_tokenstring (secret)
DATACONTRACT_S3_REGIONs3_regionstring

Snowflake

Environment variableConfig fieldTypeNotes
DATACONTRACT_SNOWFLAKE_USERNAMEsnowflake_usernamestring
DATACONTRACT_SNOWFLAKE_PASSWORDsnowflake_passwordstring (secret)
DATACONTRACT_SNOWFLAKE_AUTHENTICATORsnowflake_authenticatorstring
DATACONTRACT_SNOWFLAKE_ROLEsnowflake_rolestring
DATACONTRACT_SNOWFLAKE_TOKENsnowflake_tokenstring (secret)
DATACONTRACT_SNOWFLAKE_PASSCODEsnowflake_passcodestring (secret)
DATACONTRACT_SNOWFLAKE_PRIVATE_KEYsnowflake_private_keystring (secret)
DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_FILEsnowflake_private_key_filestring
DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_FILE_PWDsnowflake_private_key_file_pwdstring (secret)
DATACONTRACT_SNOWFLAKE_WAREHOUSEsnowflake_warehousestring
DATACONTRACT_SNOWFLAKE_CREATE_OBJECT_UDFSsnowflake_create_object_udfsboolean
DATACONTRACT_SNOWFLAKE_LOGIN_TIMEOUTsnowflake_login_timeoutinteger
DATACONTRACT_SNOWFLAKE_NETWORK_TIMEOUTsnowflake_network_timeoutinteger
DATACONTRACT_SNOWFLAKE_SOCKET_TIMEOUTsnowflake_socket_timeoutinteger
DATACONTRACT_SNOWFLAKE_HOSTsnowflake_hoststring
DATACONTRACT_SNOWFLAKE_PORTsnowflake_portinteger
DATACONTRACT_SNOWFLAKE_HOMEsnowflake_homestring
DATACONTRACT_SNOWFLAKE_CONNECTIONS_FILEsnowflake_connections_filestring
DATACONTRACT_SNOWFLAKE_DEFAULT_CONNECTION_NAMEsnowflake_default_connection_namestring
DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_PATHsnowflake_private_key_pathstringDeprecated, use DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_FILE
DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_PASSPHRASEsnowflake_private_key_passphrasestring (secret)Deprecated, use DATACONTRACT_SNOWFLAKE_PRIVATE_KEY_FILE_PWD
DATACONTRACT_SNOWFLAKE_CONNECTION_TIMEOUTsnowflake_connection_timeoutintegerDeprecated, use DATACONTRACT_SNOWFLAKE_LOGIN_TIMEOUT
DATACONTRACT_SNOWFLAKE_ACCOUNTsnowflake_accountstringOverrides account from the contract's servers block
DATACONTRACT_SNOWFLAKE_DATABASEsnowflake_databasestringOverrides database from the contract's servers block
DATACONTRACT_SNOWFLAKE_SCHEMAsnowflake_schemastringOverrides schema from the contract's servers block

SQL Server

Environment variableConfig fieldTypeNotes
DATACONTRACT_SQLSERVER_AUTHENTICATIONsqlserver_authenticationstring
DATACONTRACT_SQLSERVER_USERNAMEsqlserver_usernamestring
DATACONTRACT_SQLSERVER_PASSWORDsqlserver_passwordstring (secret)
DATACONTRACT_SQLSERVER_CLIENT_IDsqlserver_client_idstring
DATACONTRACT_SQLSERVER_CLIENT_SECRETsqlserver_client_secretstring (secret)
DATACONTRACT_SQLSERVER_DRIVERsqlserver_driverstring
DATACONTRACT_SQLSERVER_ENCRYPTED_CONNECTIONsqlserver_encrypted_connectionboolean
DATACONTRACT_SQLSERVER_TRUST_SERVER_CERTIFICATEsqlserver_trust_server_certificateboolean
DATACONTRACT_SQLSERVER_TRUSTED_CONNECTIONsqlserver_trusted_connectionboolean
DATACONTRACT_SQLSERVER_HOSTsqlserver_hoststringOverrides host from the contract's servers block
DATACONTRACT_SQLSERVER_PORTsqlserver_portintegerOverrides port from the contract's servers block
DATACONTRACT_SQLSERVER_DATABASEsqlserver_databasestringOverrides database from the contract's servers block

Trino

Environment variableConfig fieldTypeNotes
DATACONTRACT_TRINO_AUTHENTICATIONtrino_authenticationstring
DATACONTRACT_TRINO_USERNAMEtrino_usernamestring
DATACONTRACT_TRINO_PASSWORDtrino_passwordstring (secret)
DATACONTRACT_TRINO_JWT_TOKENtrino_jwt_tokenstring (secret)
DATACONTRACT_TRINO_HOSTtrino_hoststringOverrides host from the contract's servers block
DATACONTRACT_TRINO_PORTtrino_portintegerOverrides port from the contract's servers block
DATACONTRACT_TRINO_CATALOGtrino_catalogstringOverrides catalog from the contract's servers block
DATACONTRACT_TRINO_SCHEMAtrino_schemastringOverrides schema from the contract's servers block

Process-level variables are not Config options and stay environment-only: DATACONTRACT_CLI_DEBUG (debug logging), DATACONTRACT_CLI_API_KEY (see API), and DATACONTRACT_SYSTEM_TRUSTSTORE (see the command reference).

Precedence

Within one operation, resolution is:

  1. Explicit config for the options it sets: the Config object or dict passed to DataContract, the loaded --config-file, or the request's datacontract-* headers.
  2. Environment variables for everything the explicit config leaves unset.
  3. .env fills in environment variables that are not already set (it never overrides).

So a committed team config file can hold defaults, CI can override single values via environment variables, and code can override everything.

Notes for specific sources

  • Snowflake: only the documented DATACONTRACT_SNOWFLAKE_* options are passed to the connector. Unknown names are ignored with a warning; use a connections.toml for connector parameters the CLI does not support directly.
  • AWS sources (S3, Athena, Redshift IAM, Glue): when no DATACONTRACT_S3_* options are set, boto3's own credential chain applies (aws sso login, AWS_PROFILE, instance roles, GitHub OIDC). The same credential set is used to read data contracts from s3:// locations.