Skip to content

Commit 5fe4ddb

Browse files
author
Christopher Giroir
committed
doc: add cloud secrets docs
1 parent f4fa53f commit 5fe4ddb

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

docs/cloud/features/scheduler/scheduler.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,58 @@ Tobiko Cloud automatically manages Python dependencies of your Python macros and
167167

168168
SQLMesh automatically infers which Python libraries are used by statically analyzing the code of your models and macros.
169169

170-
For fine-grained control, dependencies can be specified, pinned, or excluded using the `sqlmesh-requirements.lock` file. See the [Python library dependencies](../../../guides/configuration.md#python-library-dependencies) section in the SQLMesh configuration guide for more information.
170+
For fine-grained control, dependencies can be specified, pinned, or excluded using the `sqlmesh-requirements.lock` file. See the [Python library dependencies](../../../guides/configuration.md#python-library-dependencies) section in the SQLMesh configuration guide for more information.
171+
172+
## Secrets
173+
174+
Tobiko Cloud provides a way for you to provide environment variables that will
175+
be injected into the environment when running your python models.
176+
177+
In your cloud instance you can find Secrets under the Settings section and will
178+
look like this:
179+
180+
![secrets_panel](./scheduler/secrets.png)
181+
182+
In this example, only one secret has been defined: `MY_SECRET`. From this panel
183+
you can create a new secret, edit the value of your secrets, or remove them. You
184+
can not view the value of any previously created secret.
185+
186+
Secret names must start with a letter or an underscore. They may only include
187+
letters, numbers and underscores (no spaces or other symbols). There are no
188+
limits or restrictions on the value of secrets. We recommend base64 encoding
189+
secrets if they contain binary data.
190+
191+
### Example Secret Use
192+
193+
```python
194+
import os
195+
import typing as t
196+
from datetime import datetime
197+
198+
from sqlmesh import ExecutionContext, model
199+
200+
@model(
201+
"my_model.name",
202+
columns={
203+
"column_name": "int",
204+
},
205+
)
206+
def execute(
207+
context: ExecutionContext,
208+
start: datetime,
209+
end: datetime,
210+
execution_time: datetime,
211+
**kwargs: t.Any,
212+
) -> pd.DataFrame:
213+
214+
# Read a secret from the MY_SECRET environment variable
215+
my_secret = os.environ["MY_SECRET"]
216+
```
217+
218+
!!! warning "Protecting Secrets"
219+
220+
It's very important that you read environment variables from inside the models
221+
`execute` function and not in the global scope. If the variable is loaded in the
222+
global scope than the value will be read from your local system and saved
223+
into the rendered version of this model, instead of loaded at runtime on our
224+
executors.
57.2 KB
Loading

0 commit comments

Comments
 (0)