TraGicCode / tragiccode-azure_key_vault

Pull secrets from Azure's key vault with this puppet module.
Apache License 2.0
6 stars 16 forks source link

SecretNotFound error messages with two KeyVaults #87

Closed sriharim closed 2 years ago

sriharim commented 2 years ago

Hi,

Thanks for the module. I am using a latest version of this module.

I have an issue with warning messages regarding SecretNotFound .

I have added two key vaults in hiera.yaml

Calling secrets from hierdata - choco_password: "%{lookup('chocolatey-password')}"

chocolatey-password password is configured in Platform Key Vault Secrets

Any chance to modify this behaviour, check secrets in both KeyVaults. If not found secrets in both KeyVaults, then need to trigger the warning message.

Thanks, Hari

TraGicCode commented 2 years ago

Hey @sriharim ,

I'm sorry for responding so late to this as i didn't see any notifications for this github issue.

It looks like when a secret is not found in a vault, the code is throwing an exception which is causing it to be logged as a warning as shown in the below permalinks.

Exception thrown https://github.com/TraGicCode/tragiccode-azure_key_vault/blob/f08d3313b53fe3031ce0bb0d13e918601b6b38e1/lib/puppet_x/tragiccode/azure.rb#L30

Log as warning https://github.com/TraGicCode/tragiccode-azure_key_vault/blob/f08d3313b53fe3031ce0bb0d13e918601b6b38e1/lib/puppet/functions/azure_key_vault/lookup.rb#L48-L50

I believe i can fix this by simply checking for 404 not found returned by the azure key vault and not throwing an exception. I will see what i can come up and create a PR.

Would you be available to test this once it's done?

TraGicCode commented 2 years ago

Fixed in #88