Skip to content

Commit

Permalink
feat: Add docs for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
xdoardo committed Jul 17, 2024
1 parent 8992f6a commit c4ce918
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/edge/learn/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"instaboot": "InstaBoot",
"deployment-modes": "Deployment Modes",
"remote-sessions": "Remote Sessions",
"connecting-domains-to-edge": "Connecting Custom Domains to Edge"
"connecting-domains-to-edge": "Connecting Custom Domains to Edge",
"secrets": "Secrets"
}
144 changes: 144 additions & 0 deletions pages/edge/learn/secrets.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { Callout } from "nextra-theme-docs";

### Managing secrets related to an app (`wasmer app secrets`)
You can manage secure environment variables - from now on simply _secret_ - tied to your
apps with the `wasmer app secrets` subcommand.

```sh
$ wasmer app secrets
...

Commands:
create Create a new secret related to an Edge app
delete Delete an existing secret related to an Edge app
reveal Reveal the value of an existing secret related to an Edge app
list Retrieve the value of an existing secret related to an Edge app
update Update an existing secret related to an Edge app
help Print this message or the help of the given subcommand(s)
```

#### Creating secrets
The `wasmer app secrets create` command allows you to create a new secret for
your app. The command is able to automatically infer which app you want to tie
your secrets to from simply executing the command in a directory with an
`app.yaml` configuration file. The CLI also has the `--app` and `--app-dir`
flags to specify the app to tie secrets to directly from the command line.

You can specify the name and value of the secret directly as arguments of the
CLI command:
```sh
$ wasmer app secrets create MY_NEW_SECRET "its value"
Succesfully created secret(s):
MY_NEW_SECRET
```

If you want to create multiple secrets in bulk, the subcommand offers the
`--from-file` flag that allows you to specify a `.env`-like file from which
secrets are read off:
```sh
$ cat .env
QUOTH_THE_RAVEN="NEVERMORE"
AGAIN_QUOTH_THE_RAVEN="NEVERMORE"

$ wasmer app secrets create --from-file=.env
Succesfully created secret(s):
QUOTH_THE_RAVEN
AGAIN_QUOTH_THE_RAVEN
```

#### Listing secrets
The `wasmer app secrets list` command allows you to list - but not reveal - all
the secrets tied to your app and when they were last updated. The command is
able to automatically infer which app you want to tie your secrets to from
simply executing the command in a directory with an `app.yaml` configuration
file. The CLI also has the `--app` and `--app-dir` flags to specify the app to
tie secrets to directly from the command line.

```sh
$ wasmer app secrets list
Name Last updated
MY_NEW_SECRET 11m 59s ago
QUOTH_THE_RAVEN 3m 34s ago
AGAIN_QUOTH_THE_RAVEN 3m 34s ago
```

#### Revealing secrets
The `wasmer app secrets reveal` command allows you to reveal a secret. The
command is able to automatically infer which app you want to tie your secrets
to from simply executing the command in a directory with an `app.yaml`
configuration file. The CLI also has the `--app` and `--app-dir` flags to
specify the app to tie secrets to directly from the command line.

```sh
$ wasmer app secrets reveal QUOTH_THE_RAVEN
NEVERMORE
```

If you want to reveal all the secrets tied to the selected app, use the `--all` flag:
```sh
$ wasmer app secrets reveal --all
MY_NEW_SECRET="its value"
QUOTH_THE_RAVEN="NEVERMORE"
AGAIN_QUOTH_THE_RAVEN="NEVERMORE"
```

#### Updating secrets
The `wasmer app secrets update` command allows you to update an existing secret for
your app. The command is able to automatically infer which app you want to tie
your secrets to from simply executing the command in a directory with an
`app.yaml` configuration file. The CLI also has the `--app` and `--app-dir`
flags to specify the app to tie secrets to directly from the command line.

You can specify the name and value of the secret directly as arguments of the
CLI command:
```sh
$ wasmer app secrets update QUOTH_THE_RAVEN "*nevermore*"
Succesfully updated secret(s):
QUOTH_THE_RAVEN
```

If you want to update multiple secrets in bulk, the subcommand offers the
`--from-file` flag that allows you to specify a `.env`-like file from which
secrets are read off:
```sh
$ cat .env
QUOTH_THE_RAVEN="*nevermore*"
AGAIN_QUOTH_THE_RAVEN="*neeeevermoreee!*"

$ wasmer app secrets create --from-file=.env
Succesfully created secret(s):
QUOTH_THE_RAVEN
AGAIN_QUOTH_THE_RAVEN
```

#### Deleting secrets
The `wasmer app secrets delete` command allows you to delete an existing secret for
your app. The command is able to automatically infer which app you want to tie
your secrets to from simply executing the command in a directory with an
`app.yaml` configuration file. The CLI also has the `--app` and `--app-dir`
flags to specify the app to tie secrets to directly from the command line.

<Callout type='warning'>
Warning: once deleted, secrets cannot be recovered.
</Callout>

You can specify the name of the secret directly as arguments of the
CLI command. In order to avoid users inadvertedly delete a secret, by default
the command asks the user for confirmation:
```sh
$ wasmer app secrets delete QUOTH_THE_RAVEN
✔ Delete secret 'QUOTH_THE_RAVEN'? · yes
Correctly deleted secret 'QUOTH_THE_RAVEN'
```

To stop the CLI from asking you safety confirmations, just use the `--force` flag:
```sh
$ wasmer app secrets delete AGAIN_QUOTH_THE_RAVEN --force
Correctly deleted secret 'AGAIN_QUOTH_THE_RAVEN'
```

If you don't need any of your secrets anymore and want to delete all
the secrets tied to the selected app, you can use the `--all` flag. This command will
ask the user confirmation before deleting each secret, one by one.
If you are completely sure of deleting all your secrets, you can combine the `--all` flag
with the `--force` flag.

0 comments on commit c4ce918

Please sign in to comment.