Skip to content

Commit 40e9e99

Browse files
Felonious-Spellfirerohitgr7
authored andcommitted
Updated the structure and applied feedback (#14734)
1 parent a3acbb7 commit 40e9e99

File tree

1 file changed

+63
-18
lines changed

1 file changed

+63
-18
lines changed

docs/source-app/glossary/secrets.rst

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,99 @@
44
Encrypted Secrets
55
#################
66

7-
We understand that many Apps require access to private data like API keys, access tokens, database passwords, or other credentials. And that you need to protect this data.
8-
9-
Secrets provie a secure way to make private data like API keys or passwords accessible to your app, without hardcoding. You can use secrets to authenticate third-party services/solutions.
7+
Is your App using data or values (for example: API keys or access credentials) that you don't want to expose in your App code? If the answer is yes, you'll want to use Secrets. Secrets are encrypted values that are stored in the Lightning.ai database and are decrypted at runtime.
108

119
.. tip::
1210
For non-sensitive configuration values, we recommend using :ref:`plain-text Environment Variables <environment_variables>`.
1311

14-
*******************
15-
Overview of Secrets
16-
*******************
17-
18-
The ``--secret`` option has been added to the **lightning run app** command. ``--secret`` can be used by itself or alongside ``--env``.
12+
***************
13+
What did we do?
14+
***************
1915

20-
When a Lightning App (App) **runs in the cloud**, the Secret can be exposed to the App using environment variables.
16+
When a Lightning App (App) **runs in the cloud**, a Secret can be exposed to the App using environment variables.
2117
The value of the Secret is encrypted in the Lightning.ai database, and is only decrypted and accessible to
2218
LightningFlow (Flow) or LightningWork (Work) processes in the cloud (when you use the ``--cloud`` option running your App).
2319

2420
----
2521

22+
**********************
23+
What were we thinking?
24+
**********************
25+
26+
Many Apps require access to private data like API keys, access tokens, database passwords, or other credentials. You need to protect this data.
27+
We developed this feature to provide you with a secure way to store this data in a way that is accessible to Apps so that they can authenticate third-party services/solutions.
28+
29+
----
30+
2631
*********************
2732
Use Encrypted Secrets
2833
*********************
2934

30-
First, a Secret must be created using the admin web UI. Once you create a Secret, you can bind it to any of your Apps. You do not need to create a new Secret for each App if the Secret value is the same.
35+
To use Encrypted Secrets:
3136

32-
.. note::
33-
Secret names must start with a letter and can only contain letters, numbers, dashes, and periods. The Secret names must comply with `RFC1123 naming conventions <https://www.rfc-editor.org/rfc/rfc1123>`_. The Secret value has no restrictions.
37+
#. Log in to your lightning.ai account, go to **Secrets**, and create the Secret (provide a name and value for the secret).
38+
39+
.. note:: Once you create a Secret, you can bind it to any of your Apps. You do not need to create a new Secret for each App if the Secret value is the same.
3440

35-
In the example below, we already used the admin UI to create a Secret named ``my-secret`` with the value ``some-value``` and will bind it to the environment variable ``MY_APP_SECRET`` within our App. The binding is accomplished by using the ``--secret`` option when running the App from the Lightning CLI.
41+
#. Prepare an environment variable to use with the Secret in your App.
3642

37-
The ``--secret``` option works similar to ``--env``, but instead of providing a value, you provide the name of the Secret which will be replaced with with the value that you want to bind to the environment variable:
43+
#. Use the following command to add the Secret to your App:
3844

3945
.. code:: bash
4046
41-
lightning run app app.py --cloud --secret MY_APP_SECRET=my-secret
47+
lightning run app app.py --cloud --secret <environment-variable>=<secret-name>
4248
4349
The environment variables are available in all Flows and Works, and can be accessed as follows:
4450

4551
.. code:: python
4652
4753
import os
4854
49-
print(os.environ["MY_APP_SECRET"])
55+
print(os.environ["<environment-variable>"])
5056
51-
The code above will print out ``some-value``.
57+
The ``--secret`` option can be used for multiple Secrets, and alongside the ``--env`` option.
5258

53-
The ``--secret`` option can be used for multiple Secrets, and alongside the ``--env`` option:
59+
Here's an example:
5460

5561
.. code:: bash
5662
5763
lightning run app app.py --cloud --env FOO=bar --secret MY_APP_SECRET=my-secret --secret ANOTHER_SECRET=another-secret
64+
65+
----
66+
67+
Example
68+
^^^^^^^
69+
70+
The best way to show you how to use Encrypted Secrets is with an example.
71+
72+
First, log in to your `lightning.ai account <https://lightning.ai/>`_ and create a Secret.
73+
74+
.. raw:: html
75+
76+
<br />
77+
<video id="background-video" autoplay loop muted controls poster="https://pl-flash-data.s3.amazonaws.com/assets_lightning/docs/images/storage/encrypted_secrets_login.png" width="100%">
78+
<source src="https://pl-flash-data.s3.amazonaws.com/assets_lightning/docs/images/storage/encrypted_secrets_login.mp4" type="video/mp4" width="100%">
79+
</video>
80+
<br />
81+
<br />
82+
83+
.. note::
84+
Secret names must start with a letter and can only contain letters, numbers, dashes, and periods. The Secret names must comply with `RFC1123 naming conventions <https://www.rfc-editor.org/rfc/rfc1123>`_. The Secret value has no restrictions.
85+
86+
After creating a Secret named ``my-secret`` with the value ``some-secret-value`` we'll bind it to the environment variable ``MY_APP_SECRET`` within our App. The binding is accomplished by using the ``--secret`` option when running the App from the Lightning CLI.
87+
88+
The ``--secret``` option works similar to ``--env``, but instead of providing a value, you provide the name of the Secret that is replaced with with the value that you want to bind to the environment variable:
89+
90+
.. code:: bash
91+
92+
lightning run app app.py --cloud --secret MY_APP_SECRET=my-secret
93+
94+
The environment variables are available in all Flows and Works, and can be accessed as follows:
95+
96+
.. code:: python
97+
98+
import os
99+
100+
print(os.environ["MY_APP_SECRET"])
101+
102+
This code prints out ``some-secret-value``.

0 commit comments

Comments
 (0)