I am using below code to read config data from HC Vault,
package com.dell.eventreader.config
import com.bettercloud.vault.json.Json
import com.bettercloud.vault.{Vault, VaultConfig}
object VaultConfig {
def main(args: Array[String]): Unit = {
// Configuration properties
val host = "vault.com"
val port = 443
val scheme = "https"
val namespace = "my/namespace/path/"
val roleId = "sample-role"
val secretId = "sample-secret"
// Initialize Vault configuration
val vaultConfig = new VaultConfig()
.address(s"$scheme://$host:$port")
.nameSpace(namespace)
.build()
// Create a Vault client
val vault = new Vault(vaultConfig)
// Specify the path to the secret in Vault
val secretPath = "/kv/data/scala-poc"
// Authenticate using role ID and secret ID
vault.auth().loginByAppRole(roleId, secretId)
// Read the secret from Vault
val response = vault.logical().read(secretPath)
// Extract the configuration from the response
val configMap = response.getData
println("Retrieved configuration from Vault:")
configMap.forEach((key, value) => println(s"$key -> $value"))
}
}
There is no error, but it does not print any config data either. However, there are some config data as I can see from Vault UI. There, the navigation goes like - namespace-path -> kv -> scala-poc
As there is no error shown, I suppose the Vault configurations are correct and have been set correctly as well. I am unsure of what will be the correct secretPath if not this one. Tried with /kv/scala-poc as well, but no luck. Also, I don't find anything to set kv as backend here. I can confirm that kv version 2 is being used this side.
I am using below code to read config data from HC Vault,
There is no error, but it does not print any config data either. However, there are some config data as I can see from Vault UI. There, the navigation goes like - namespace-path -> kv -> scala-poc
As there is no error shown, I suppose the Vault configurations are correct and have been set correctly as well. I am unsure of what will be the correct secretPath if not this one. Tried with /kv/scala-poc as well, but no luck. Also, I don't find anything to set kv as backend here. I can confirm that kv version 2 is being used this side.
Unable to identify what's missing in here.