Working with secrets
Secrets enable storing sensitive data in encrypted form and using it securely within your project code.
Creating a secret
-
Select the project in your community or on the DataSphere home page
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 name must be 2 to 63 characters long.
-
In the Value field, enter a value to store in encrypted form.
-
Click Create. You will see a page with detailed info on the secret you created.
Sharing a secret
Note
You can only share resources within a single organization, between communities created in the same availability zone.
To share a secret within 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 project in your community or on the DataSphere home page
in the Recent projects tab. - Under Project resources, click
Secret. - Select the secret from the list.
- Go to the Access tab.
- Enable the visibility option next to the name of the community you want to share the secret in.
To make a secret available for use in a different project, the project editor needs to add that secret on the Shared tab.
Accessing a secret from 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 a secret
-
Select the project in your community or on the DataSphere home page
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. You will see a page with detailed info on the secret you created.
A copied secret is not linked to the original: you can edit and delete the former without affecting the latter.
Updating a secret
-
Select the project in your community or on the DataSphere home page
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 by editing its name and contents.
- Click Save.
You cannot edit a secret created in a different project, but you can edit its copy.
Deleting a secret
-
Select the project in your community or on the DataSphere home page
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
In fact, resource deletion can take up to 72 hours.