Documentation
Library
Secret

Secret

Secret resources are used to store sensitive information, such as API keys, database passwords, etc. This type of data is kept in secure storage within the runtime platform, like AWS's Secrets Manager or Kubernetes's Secret. These details can be retrieved at runtime using the get method.

How to Use

Creating a Resource

from pluto_client import Secret
secret = Secret("OPENAI_API_KEY", os.environ.get("OPENAI_API_KEY"))
💡

At present, the creation of resources only supports simple assignment scenarios and does not allow for manipulation of environmental variables during resource creation.

secret = Secret("OPENAI_API_KEY", os.environ.get("OPENAI_API_KEY") or "default")  # Not supported
secret = Secret("OPENAI_API_KEY", os.environ.get("OPENAI_API_KEY", "default"))  # Supported

Accessing Data

from pluto_client import Function, Secret
 
secret = Secret("OPENAI_API_KEY", os.environ.get("OPENAI_API_KEY"))
 
def return_secret():
    return secret.get()
 
Function(return_secret)
💡

It's important to mention that when the Secret resource is utilized by runtime functions like Function, the local environment variables that the Secret relies on will be automatically incorporated into the environment variable configuration of these runtime functions.