PowerShell / Modules

MIT License
111 stars 25 forks source link

[SecretManagement] Get-SecretVaultRegistrationSettings #89

Open itfranck opened 4 years ago

itfranck commented 4 years ago

Add a cmdlet to get expected registration setting for a certain provider.

Currently, when you register an external vault, you have to use the -VaultParameters settings, which is great because it is flexible. For that same reason, it make it impossible to know what parameter to pass without referring to some documentation.

Proposed technical implementation details (optional)

It would be nice to be able to get a vault parameter hashtable of all the available settings that can be passed down. Something like

# Return a hashtable of the expected VaultParameters
$Settings = Get-SecretVaultRegistrationSettings -Module 'Az.Keyvault' 

could return for instance the parameters expected for a new vault registration for that provider. For an az keyvault, you would get the following hashtables stored in the $settings variable

@{ AZKVaultName = ''; SubscriptionId = '' }

Then, all you would do is :

$Settings.AZKVaultName = 'MyKeyvault'
$Settings.SubscriptionId = 'cd7e3201-fa28-4283-8289-8c3bd66f62cf'
Register-SecretVault -Name 'MyAzKeyVault' -ModuleName 'Az.Keyvault' -VaultParameters $Settings

That way, you wouldn't have to necessarily check the documentation for each providers (provided you are familiar with the parameter name) to register a new vault.

As this module gain interest and the number of secret providers grow, it might be a useful addition.

edit: Just an additional thought. Maybe the object retunned could be a class so parameter types could be enforced The class could be implemented with an interface to force a [Hashtable]Settings property, that the provider would use to convert the class property values to the proper hashtable format accepted by Register-SecretVault