Give a function secrets and config
A function sees only the configuration it declares in code. The values live on the platform, set per function, and the runner hands them over when it fetches the function’s settings. The function never holds a platform credential.
| Kind | Declared with | Value |
|---|---|---|
| Config | Config("KEY") |
plain text, readable back |
| Secret | Secret("KEY") |
write-only: the settings list shows it blank |
| Database | DB("name") |
a connection string, treated as a secret |
Promoting a version is refused while any declared key, secret or database has no value, so a forgotten setting fails at deploy time rather than in production. For how config differs from secrets across the platform, see Configuration and secrets.
Set values
Section titled “Set values”fcdev fn set billing.invoice-pdf --config GREETING=Hi --secret STRIPE_KEY=sk_live_...fcdev fn set billing.invoice-pdf --db main=postgres://user:pass@db.example.com/billingSetting values needs function manage and, for --secret and --db,
platform:function:secret:manage. For local runs, pass the same values to fcdev fn dev with
--config, --secret and --db NAME=DSN; secret values are masked in everything it prints.
Read them in code with the SDK: greeting.Get(ctx) (Go), greeting.get() (TypeScript),
ctx.config_get("GREETING") / ctx.secret_get("KEY") (Rust), ctx.config().get(key) /
ctx.secrets().require(key) (Java). A missing optional key is not found, not an error.
Databases
Section titled “Databases”DB("main") gives a database/sql handle in Go, and query / exec / transaction in Rust and
TypeScript. In Java, ctx.dataSource("main") gives a JDBC DataSource (PostgreSQL only). Statements
bind with ? placeholders. A result is limited to 10,000 rows or 8 MiB, and a transaction still open
when the call ends is rolled back. The pool belongs to the runner (in the JVM host, one pool per distinct
connection string, shared by every function bound to it). Borrow a connection per call and close it.
Secrets that point at AWS
Section titled “Secrets that point at AWS”In the console, the secret form has a Stored as selector: Value (stored encrypted), AWS
Parameter Store or AWS Secrets Manager. For a value, type the secret; for the other two, type the
parameter name (shown after aws-ps://) or the secret’s name or ARN, with #key to take one key of a JSON
secret (shown after aws-sm://). The console builds the reference described below, so you do not type
the scheme. A reference is shown on the settings list, with its store.
A secret or database setting may be a reference to a secret kept in AWS, instead of the secret itself, so it is set and rotated in one place:
fcdev fn set billing.invoice-pdf --secret STRIPE_KEY=aws-sm://prod/billing/stripe#apiKeyfcdev fn set billing.invoice-pdf --secret ERP_TOKEN=aws-ps:///billing/np/erp-token| Reference | Resolves to |
|---|---|
aws-sm://<name-or-arn> |
the secret’s string value |
aws-sm://<name-or-arn>#<key> |
field <key> of the secret read as a JSON object (a string as is, a number or boolean as its text; a missing, null, object or array field is an error) |
aws-ps://<parameter> |
the parameter’s value, decrypted (a path parameter is aws-ps:///path/to/param) |
How it behaves:
- The platform stores the reference, never the secret, and reads it when a runner fetches the
function’s settings, caching it for
FC_SECRET_REFERENCE_TTL(5 minutes). A rotation in AWS reaches the function within that time with nothing to change here. - If AWS cannot be reached, the last value is served for up to
FC_SECRET_REFERENCE_MAX_STALE(1 hour). - A reference that cannot be resolved is left out of the function’s settings, so
require(...)fails at the point of use, and the platform logs an error naming the function, key, reference and reason:SECRET_REFERENCE_NOT_FOUND,_DENIED,_KEY_MISSING,_UNAVAILABLEor_NOT_ALLOWED. - The platform accepts only references starting with a prefix in
FC_SECRET_REFERENCE_ALLOW(otherwise400 SECRET_REFERENCE_NOT_ALLOWED). Its AWS role must be allowed to read them (secretsmanager:GetSecretValue,ssm:GetParameter,kms:Decrypt). Other schemes (gcp-sm://,vault://,env://) are refused with400 SECRET_REFERENCE_UNSUPPORTED. - A reference is not itself a secret: the settings list shows it, where a real secret is blank.
Do not log them
Section titled “Do not log them”Secrets and the platform token never appear in a Java toString or log, and trace records replace
declared secrets with a redaction. Credentials you obtain yourself at run time (a session id from a
vendor login) are not known to the platform: in a Java function call ctx.conceal(value) when you get
one so it stays out of trace records. See Switch on trace logs and read them.