Skip to content

Commit cc8bb69

Browse files
authored
EA: env vars as files (#2395)
1 parent 02726f7 commit cc8bb69

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

deploy/early-access/reference/env-vars-and-contexts.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,30 @@ Access environment variables using the `Deno.env.get` API:
9595
const myEnvVar = Deno.env.get("MY_ENV_VAR");
9696
```
9797

98+
## Exposing an environment variable as a file
99+
100+
Environment variables can be exposed as a file instead of a regular environment
101+
variable by toggling the "Expose as file" option.
102+
103+
When this option is enabled, the environment variable's value is stored in a
104+
temporary file in the application's file system. The environment variable then
105+
contains the file path to this temporary file instead of the value itself.
106+
107+
To read the value, you can use the `Deno.readTextFile` API in combination with
108+
`Deno.env.get`:
109+
110+
```ts
111+
// Assuming MY_ENV_VAR is set to expose as a file
112+
const value = await Deno.readTextFile(Deno.env.get("MY_ENV_VAR"));
113+
```
114+
115+
This is useful for values that are too large for environment variables or when
116+
you want to avoid exposing sensitive data in the environment variable list.
117+
118+
Additionally it is useful for preexisting applications that expect certain
119+
environment variables to point to files, such as `PGSSLROOTCERT` for Postgres CA
120+
certificates.
121+
98122
## Predefined environment variables
99123

100124
Deno Deploy<sup>EA</sup> provides these predefined environment variables in all

0 commit comments

Comments
 (0)