Skip to content

Commit

Permalink
add explanation about secrets in environment variables
Browse files Browse the repository at this point in the history
Update Note about secrets in connection. Add local dev option.

Explain env variable keys naming convention and how to set them for `modus dev`.
  • Loading branch information
rderbier committed Nov 5, 2024
1 parent dd35984 commit 8f298eb
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions modus/app-manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ connection types:
**Don't include secrets directly in the manifest!**

If your connection requires authentication, you can include _placeholders_ in
connection properties which resolve to their respective secrets at runtime. Set
the actual secrets via the Hypermode Console, where they're securely stored
until needed.
connection properties which resolve to their respective secrets at runtime.

When deployed on Hypermode, set the actual secrets via the Hypermode Console,
where they're securely stored until needed.

When developing locally,
[set secrets using environment variables](#working-locally-with-secrets).

</Warning>

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

### Working locally with secrets

When you run the app locally using `modus dev`, the runtime replaces all the
placeholders of the manifest with values from environment variables defined in
your operating system or in `.env` files.

The environment variables keys must be upper case and follow the naming
convention:

`MODUS_<CONNECTION NAME>_<PLACEHOLDER>`

For example, with the following manifest:

```json modus.json
{
"connections": {
"openai": {
"type": "http",
"baseUrl": "https://api.openai.com/",
"headers": {
"Authorization": "Bearer {{API_KEY}}"
}
}
}
}
```

Modus runtime substitutes `{{API_KEY}}` with the value of the environment
variable `MODUS_OPENAI_API_KEY`

An easy way to define the environment variables when running `modus dev` is to
use the file `.env.dev.local` located in your app folder.

For the previous manifest, we can set the key in the .env.dev.local file as
follow:

```text .env.dev.local
MODUS_OPENAI_API_KEY="your actual openai key"
```

You must exclude `.env` files from your source control. `modus new` does that
automatically for you when creating the project.

## Models

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

0 comments on commit 8f298eb

Please sign in to comment.