This example shows how camel-hashicorp-vault
can be used to configure beans using data from HashiCorp Vault
Run HashiCorp Vault
docker run --cap-add=IPC_LOCK -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' -e 'VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200' -p 8200:8200 hashicorp/vault:1.16.1`
Go to http://localhost:8200/ui/vault/secrets/secret/kv/list
login with method Token and token myroot
and create the following secrets:
-
a secret named
myDatabase
-
a secret data
myPassword
with valuemysecretpassword
-
a secret data
myUsername
with valuepostgres
-
a secret data
myJdbcURL
with valuejdbc:postgresql://localhost:5432/postgres
Run the database container
docker run -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
You can run this example using
mvn spring-boot:run
To execute the routes:
-
verify the table is empty (no data on response)
curl http://localhost:8080/api/cars
-
insert data
curl --header "Content-Type: application/json" --request POST --data '{"brand": "Ford", "model": "Mustang", "year": 2024}' http://localhost:8080/api/cars
-
verify the data has been persisted
curl http://localhost:8080/api/cars
If you hit any problem using Camel or have some feedback, then please let us know.
We also love contributors, so get involved :-)
The Camel riders!