SECRET()

All functions > SOURCE > SECRET()

A secret of the serving engine's environment, for a source's credentials

Signatures

Returns: The secret, resolved by the serving engine when it connects

SECRET(provider: VARCHAR, name: VARCHAR, [key: VARCHAR]) → VARCHAR
sql
ParameterTypeRequiredDescription
providerVARCHARYes'env' (an environment variable) or 'file' (a file's content, such as a Docker or Kubernetes secret)
nameVARCHARYesThe variable's name or the file's path
keyVARCHARNoThe field to read when the value is a JSON object

Notes

  • Only in the properties of a source (SOURCE_DB, SOURCE_KV, SOURCE_HTTP), such as password = SECRET('env', 'PG_PASSWORD'); anywhere else it is refused (SECRET-OUTSIDE-SOURCE)
  • The registry stores the reference, never the value: the serving engine reads it each time it connects, so a rotated secret is used from the next connection
  • A missing variable or file shows as an ERROR of the source in RECOMPILE SERVING

See also

Examples

A database source whose password comes from an environment variable

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.EXTERNAL_JDBC.POSTGRES_CONN AS
    SOURCE_DB(
        'postgresql://featuremesh@host.docker.internal:25432/featuremesh?sslmode=disable'
        WITH (
            password = SECRET('env', 'FEATUREMESH_DEMOS_PG_PASSWORD'),
            tables=ARRAY['serving_slt_customers', 'serving_slt_customer_orders'],
            timeout='500ms'
        )
    );
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.EXTERNAL_JDBC.POSTGRES_CONNCREATEDFeature created as not exists