Can't connect Spring Cloud Vault to HCP Vault in Dev Mode Using Token Auth

281 Views Asked by At

What I have:

  • HCP Vault in Development mode
  • Simple Spring Client using Spring Cloud Vault
  • CLI Client

Desried Outcome: Inject data into a variable using HCP Vault

What is working:

  • Run Vault locally (in dev mode) and inject data into the variable
  • Get the data from the HCP Vault using vault CLI

Notes:

  • I'm generating the admin token to avoid the use of policies
  • The secrets in HCP Vault and my local Vault are identical

This is my application.yml file:

spring.application.name: my-spring-boot-app


spring.cloud.vault:
  host: vault-cluster-public-vault-fjkdsahfdjksa.hfjksdfhdsajk.hashicorp.cloud
  port: 8200
  scheme: https
  authentication: TOKEN
  token: hvs.fdsjfhdsakjfhdasjkfhdasjkfhdasjkfhdasjkfhdasjkfhdasjkfhdsakj


spring.config.import: vault://

logging.level.org: INFO
logging.level.com: INFO
1

There are 1 best solutions below

0
Alexander Tilkin On

The problem was that I was missing the namespace header.

spring.cloud.vault:
  host: vault-cluster-public-vault-fjkdsahfdjksa.hfjksdfhdsajk.hashicorp.cloud
  port: 8200
  scheme: https
  namespace: admin
  authentication: TOKEN
  token: ${VAULT_TOKEN}

spring.config.import: vault://