Base Abstraction
The secret manager acts as the one-stop shop for all the secrets to which your pipeline or stack components might need access. TheBaseSecretsManager
is implemented as follows:
Build your own custom secrets manager
If you want to create your own custom flavor for a secrets manager, you can follow the following steps:-
Create a class which inherits from the
BaseSecretsManager
class and implement theabstractmethod
s:register_secret
,get_secret
,get_all_secret_keys
,update_secret
,delete_secret
,delete_all_secrets
. -
If you need to provide any configuration, create a class which inherits from the
BaseSecretsManagerConfig
class add your configuration parameters. -
Bring both of the implementation and the configuration together by inheriting from the
BaseSecretsManagerFlavor
class. Make sure that you give aname
to the flavor through its abstract property.
- The CustomSecretsManagerFlavor class is imported and utilized upon the creation of the custom flavor through the CLI.
- The CustomSecretsManagerConfig class is imported when someone tries to register/update a stack component with this custom flavor. Especially, during the registration process of the stack component, the config will be used to validate the values given by the user. As
Config
object are inherentlypydantic
objects, you can also add your own custom validators here. - The CustomSecretsManager only comes into play when the component is ultimately in use.
CustomSecretsManagerFlavor
and the CustomSecretsManagerConfig
are implemented in a different module/path than the actual CustomSecretsManager
).
Some additional implementation details
Different providers in the space of secrets manager have different definitions of what constitutes a secret. While some providers consider a single key-value pair a secret: ('secret_name': 'secret_value'
), other providers have a slightly different definition. For them, a secret is a collection of key-value pairs: {'some_username': 'user_name_1', 'some_pwd': '1234'}
.
ZenML falls into the second category. The implementation of the different methods should reflect this convention. In case the specific implementation interfaces with a secrets manager that uses the other definition of a secret, working with tags can be helpful. See the GCPSecretsManager
for inspiration.
SecretSchemas
One way that ZenML expands on the notion of secrets as dictionaries is the secret schema. A secret schema allows the user to create and use a specific template. A schema could, for example, require the combination of a username, password and token. All schemas must sub-class from theBaseSecretSchema
.
- All Secret Schemas will need to have a defined
TYPE
. - The required and optional keys of the secret need to be defined as class variables.