Using secrets
Secrets let you store sensitive data in encrypted form and use it safely in your project code.
Creating secrets
-
Select the relevant project in your community or on the DataSphere homepage
in the Recent projects tab. -
Under Project resources, click
Secret. -
Click Create.
-
In the Name field, enter a name for the secret.
The name may contain uppercase and lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character cannot be a hyphen or underscore. The allowed length is 3 to 63 characters.
-
In the Value field, enter a value to be stored in encrypted form.
-
Click Create. This will display the created secret's info page.
Sharing secrets
Note
You can only share resources within a single organization between communities created in the same availability zone.
To share a secret in a community, you need the Editor
role in the project and the Developer
role in the community. To learn more about roles in DataSphere, see Access management in DataSphere.
-
Select the relevant project in your community or on the DataSphere homepage
in the Recent projects tab. - Under Project resources, click
Secret. - Select the appropriate secret from the list.
- Go to the Access tab.
- Enable the visibility option next to the name of the community to share the secret in.
To make a secret available for use in another project, the project editor should add it to the Shared tab.
Invoking a secret in a project cell
Once you create a secret, you can use it in project cells as an environment variable.
import os
os.environ # Getting a list of all environment variables
os.environ['<secret_name>'] # Accessing <secret_name> from environment variables
#!:bash
printenv <secret_name>
Copying secrets
-
Select the relevant project in your community or on the DataSphere homepage
in the Recent projects tab. - Under Project resources, click
Secret. - In the list of secrets, choose the one you want to copy to your project, click
, and select Clone. - Edit the name and contents of the secret to copy.
- Click Create. This will display the created secret's info page.
A copied secret is not bound to the original: you can edit and delete the former without affecting the latter.
Updating secrets
-
Select the relevant project in your community or on the DataSphere homepage
in the Recent projects tab. - Under Project resources, click
Secret. - In the list of secrets, choose the one you want to update, click
, and select Edit. - Update the secret: edit its name and contents.
- Click Save.
You cannot modify a secret created in a different project, but you can modify its copy.
Deleting secrets
-
Select the relevant project in your community or on the DataSphere homepage
in the Recent projects tab. - Under Project resources, click
Secret. - In the list of secrets, choose the one you want to delete, click
, and select Delete. - Click Confirm.
You will see a message saying that the secret has been deleted.
Warning
The actual deletion of resources can take up to 72 hours.