Skip to content

Commit 7cf97f4

Browse files
add explanation about setting secrets in environment variables (#60)
* add explanation about secrets in environment variables Update Note about secrets in connection. Add local dev option. Explain env variable keys naming convention and how to set them for `modus dev`. * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update modus/app-manifest.mdx Co-authored-by: Ryan Fox-Tyler <[email protected]> * Update app-manifest.mdx --------- Co-authored-by: Ryan Fox-Tyler <[email protected]>
1 parent dd35984 commit 7cf97f4

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

modus/app-manifest.mdx

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ connection types:
115115
**Don't include secrets directly in the manifest!**
116116

117117
If your connection requires authentication, you can include _placeholders_ in
118-
connection properties which resolve to their respective secrets at runtime. Set
119-
the actual secrets via the Hypermode Console, where they're securely stored
120-
until needed.
118+
connection properties which resolve to their respective secrets at runtime.
119+
120+
When developing locally,
121+
[set secrets using environment variables](#working-locally-with-secrets).
122+
123+
When deployed on Hypermode, set the actual secrets via the Hypermode Console,
124+
where they're securely stored until needed.
121125

122126
</Warning>
123127

@@ -324,6 +328,49 @@ This connection type supports connecting to Dgraph databases. You can use the
324328
The API key for the Dgraph database.
325329
</ResponseField>
326330

331+
### Working locally with secrets
332+
333+
When you run your app locally using `modus dev`, the runtime replaces the
334+
placeholders of the manifest with values from environment variables defined in
335+
your operating system or in `.env` files.
336+
337+
The environment variables keys must be upper case and follow the naming
338+
convention:
339+
340+
`MODUS_<CONNECTION NAME>_<PLACEHOLDER>`
341+
342+
For example, with the following manifest:
343+
344+
```json modus.json
345+
{
346+
"connections": {
347+
"openai": {
348+
"type": "http",
349+
"baseUrl": "https://api.openai.com/",
350+
"headers": {
351+
"Authorization": "Bearer {{API_KEY}}"
352+
}
353+
}
354+
}
355+
}
356+
```
357+
358+
The Modus runtime substitutes `{{API_KEY}}` with the value of the environment
359+
variable `MODUS_OPENAI_API_KEY`
360+
361+
An easy way to define the environment variables when working locally is to use
362+
the file `.env.dev.local` located in your app folder.
363+
364+
For the previous manifest, we can set the key in the .env.dev.local file as
365+
follow:
366+
367+
```text .env.dev.local
368+
MODUS_OPENAI_API_KEY="your openai key"
369+
```
370+
371+
You should exclude `.env` files from source control. Projects created with
372+
`modus new` exclude these files automatically when creating your project.
373+
327374
## Models
328375

329376
AI models are a core resource for inferencing. The `models` object in the app

0 commit comments

Comments
 (0)