Search code examples
spring-cloudhashicorp-vaultspring-cloud-vault-config

Configuring Spring Cloud Vault Config to pull from a location other than /secret


I am currently integrating Spring Cloud Vault Config into a Spring Boot application. From the home page:

Spring Cloud Vault Config reads config properties from Vaults using the application name and active profiles:

/secret/{application}/{profile}
/secret/{application}
/secret/{default-context}/{profile}
/secret/{default-context}

I would like to instead provide my own location from which to pull properties from Vault which does not start with /secret (e.g. /deployments/prod). I've been looking through the reference documentation but I haven't found anyway to specify this -- is it possible?


Solution

  • It should be done this way.

    Have a Configuration class

    @Configuration
    public class VaultConfiguration {
    
        @Bean
        public VaultConfigurer configurer() {
            return new VaultConfigurer() {
                @Override
                public void addSecretBackends(SecretBackendConfigurer configurer) {
                    configurer.add("secret/my-app/path-1");
                    configurer.add("secret/my-app/path-2");
    
                    configurer.registerDefaultGenericSecretBackends(false);
                }
            };
        }
    }
    

    This way you can scan your secrets placed in custom path

    Regards Arun