Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document secrets via config and environment variables workflow #212

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions doc/user-guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,12 @@ ploomber-cloud deploy
The command-line interface will automatically read and encrypt your secrets and include them in the deployment.
For security reasons, your `.env` file is replaced with an empty file at runtime. Ploomber only stores your encrypted secrets.

To learn how to read your secrets from within your application, see [Reading secrets.](../user-guide/secrets.md#reading-secrets)

```{note}
Ensure that you specify all the required secrets in the `.env` file whenever deploying or re-deploying an application. Secrets will not be carried over from the previous deployment.
We generally advise users to define secrets through an `.env` file. In the case this isn't possible, we've created an [alternative solution.](../user-guide/github.md#secrets)
edublancas marked this conversation as resolved.
Show resolved Hide resolved
```

To learn how to read your secrets from within your application, see [Reading secrets.](./secrets.md)


## Configure resources

You can customize the amount of `CPUs`, `RAM`, and `GPUs` that your project will use with this command:
Expand Down
39 changes: 39 additions & 0 deletions doc/user-guide/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,42 @@ If workflow needs an update a relevant message will be displayed:

Please review the workflow file and update if needed.

## Secrets

We generally advise users to define their secrets in an `.env` file. However, this isn't optimal in the case of Github deployment, since uploading an `.env` file would expose your plain secrets.

As a result, we've created a workflow where the CLI can read secrets from your local environment. To take advantage of this, follow these steps:

edublancas marked this conversation as resolved.
Show resolved Hide resolved
1. Set secrets as environment variables using `export key=value`
edublancas marked this conversation as resolved.
Show resolved Hide resolved
2. Define secret keys in `ploomber-cloud.json` under `secret-keys`
3. Push your code to deploy

For example, if I had two secrets, `key1` and `key2`, I would first set them as environment variables:

```sh
export key1=val1
export key2=val2
```

Then I would edit my `ploomber-cloud.json` to look like this:

```json
"id": "project-id-1999",
edublancas marked this conversation as resolved.
Show resolved Hide resolved
"type": "project-type",
"secret-keys": ["key1", "key2"]
```

Now, in your deployment logs, when `ploomber-cloud deploy` is ran, you should see the secrets included with this message:

```sh
edublancas marked this conversation as resolved.
Show resolved Hide resolved
Adding the following secrets to the app: key1, key2,
```

Some important notes:

- `secret-keys` should be defined as a list of strings that only includes the keys (not the values) of each secret
- If your secrets are defined in both an `.env` and `secret-keys`, the deployment will fail. You may only use one method.
- Make sure to define each secret as an environment variable AND in your `ploomber-cloud.json`.
- If a secret is defined in `ploomber-cloud.json`, but isn't set as an environment variable, the deployment will fail.
- If a secret is set as an environment variable, but isn't defined in `ploomber-cloud.json`, that secret won't be included in the deployment.

Loading