You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/2025-03-04-spring_vault.md
+38-22Lines changed: 38 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,25 +62,13 @@ First, set up a Vault instance for local development using `docker compose`:
62
62
+ timeout: 30s
63
63
+ retries: 10
64
64
+ start_period: 1s
65
-
+ vault-init:
66
-
+ image: docker.io/hashicorp/vault:latest
67
-
+ depends_on:
68
-
+ vault: {condition: service_healthy}
69
-
+ mysql: {condition: service_healthy}
70
-
+ environment:
71
-
+ - MYSQL_ROOT_PASSWORD=my_password
72
-
+ - VAULT_TOKEN=my-vault-root-token
73
-
+ - VAULT_ADDR=http://vault:8200
74
-
+ volumes:
75
-
+ - ./scripts/vault-init.sh:/vault-init.sh
76
-
+ command: sh /vault-init.sh
77
65
app:
78
66
build: .
79
67
ports: [ "8080:8080" ]
80
68
```
81
69
</details>
82
70
83
-
Then add a script to [configure the MySQL secrets engine in Vault][vault-mysql] using Vault's built-in database credential management plugins:
71
+
Once Vault is up and running, add a script to [configure the MySQL secrets engine in Vault][vault-mysql] using Vault's built-in database credential management plugins:
# mount an external config file in a location that Spring Boot will check
@@ -212,12 +232,8 @@ Also, in this demo, the Spring Boot app needs a `$VAULT_TOKEN` to authenticate:
212
232
213
233
</details>
214
234
215
-
<aside>
216
-
217
-
(This example uses the Vault root token that we configured when setting up Vault.
218
-
In anything more than a demo you should probably use one of Vault's many supported [authentication methods][vault-auth-methods] to use identity providers such as AWS, Azure, or Kubernetes to authenticate to Vault.)
219
-
220
-
</aside>
235
+
Note that this example app uses Vault's root token to authenticate to Vault for demonstration purposes only.
236
+
In production you should authenticate to Vault using a trusted identity from AWS, Azure, Kubernetes, or one of Vault's other [authentication methods][vault-auth-methods].
221
237
222
238
223
239
Now if you start your app, it should successfully initialize:
0 commit comments