Enterprise only
This tutorial downloads a small UTF-8 text object from a private S3 bucket into
a LanceDB column. You create a Secret, register a Python Function that reads it,
then refresh the column and read the downloaded text.
The AWS credentials authorize the Function’s requests to your source bucket.
LanceDB manages access to the table’s own storage separately. Registering this
Secret does not configure table storage or a storage integration.
Prepare the deployment and source object
You need:- A LanceDB Enterprise deployment with Functions and Secrets enabled, including KMS configuration for Secrets.
- The Python SDK version supported by your deployment, with
pyarrowinstalled in your local Python environment. - An existing database and root namespace (
public). Use new object names for this tutorial; creating an existing Secret or table fails. - A small UTF-8 text object in S3. The AWS identity needs
s3:GetObjecton that object. For an object encrypted with SSE-KMS, it also needskms:Decryptand permission through the key policy. Workers need network access to S3.
Run the Python blocks in order in the same script or session. The worker installs
Boto3 from the Function’s dependency declaration below; your local process does
not need Boto3.
Grant access
An administrator grants the tutorial principal access to the existing database and namespace, and permission to create its objects. For an existing role nameds3_ingest, run this SQL in the tutorial database, replacing the database and
role names as needed:
All operations also require
USAGE on the containing database and namespaces.
For example, after creating the objects, grant another existing role permission
to use the Secret with:
Connect and create the Secret
Define and register the Function
A class Function creates one S3 client per worker instance and reuses it for that instance’s rows. It reads credentials through its declared Secret binding.Add, refresh, and read the column
The Function’sstr parameters require non-nullable string input columns.
Its region initialization parameter is a fixed value for this column binding.
Hello from S3!, the row’s content contains
that text. add_columns declares an empty output column; automatic refresh is
disabled here so the explicit refresh performs the download. Subsequent reads
return the stored text without contacting S3. Updating the source object does
not automatically update an already populated column.
This example reads each complete object into worker memory and decodes UTF-8.
Use small text objects for the tutorial. Binary files need a different output
schema and decoding logic; large objects need a suitable streaming or blob
workflow. AWS request errors and invalid UTF-8 propagate as Function failures.
Alter credentials and handle expiry
After loading a complete replacement credential set into this Python process’s environment, replace the Secret’s JSON value:AWS_SESSION_TOKEN from the same temporary credential set as the new keys.
Remove an old session token when switching to long-lived keys. Updating a
parent shell’s environment does not update an already running Python process.
Alteration keeps the same Secret name, Function version, and column binding.
Future jobs capture the replacement value. A running job and its retries keep
the credential value captured for that job; alteration does not replace their
client credentials or recompute existing output rows.
Temporary credentials passed explicitly to Boto3 do not renew automatically.
Choose a credential lifetime that covers the complete refresh, including
retries. If AWS expires or revokes those credentials, subsequent S3 requests
can fail even after the Secret has been altered. Split long backfills into jobs
that fit the credential lifetime, renewing credentials between jobs.
After replacing an expired credential, submit a new refresh for unfilled rows
so it captures the new value. See
refresh behavior for recomputation and
retry controls.
Dropping a Secret prevents future jobs from resolving it, but does not recall
credentials already delivered to running work. Revoke the credential in AWS
when immediate revocation is required. Never print, return, or log the Secret’s
JSON or its fields; redaction does not protect transformed values. See
Secret delivery for more detail.