Vault isn't considering profile-specific files
See original GitHub issueI’m using spring boot 2.4.2 and spring-cloud 2020.0.1 (spring-cloud-starter-vault-config).
I have two properties files: application.properties and application-test.properties. application.properties content:
spring.application.name=app-name
spring.config.import=vault://
spring.cloud.vault.scheme=http
spring.cloud.vault.host=${VAULT_HOST}
spring.cloud.vault.port=${VAULT_PORT}
spring.cloud.vault.token=${VAULT_TOKEN}
spring.cloud.vault.kv.backend=kv-backend
VAULT_HOST, VAULT_PORT and VAULT_TOKEN are environment variables.
application-test.properties content:
spring.cloud.vault.enabled=false
Everything works fine when running with default profile. However, when running tests with the test profile (using the @ActiveProfiles("test")
annotation) in a ci/cd environment, vault ignores the spring.cloud.vault.enabled=false property and still tries to create a connection.
Log:
...
[main] DEBUG org.springframework.core.env.StandardEnvironment - Activating profiles [test]
...
[main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.cloud.vault.port' to int
...
Caused by: java.lang.NumberFormatException: For input string: "${VAULT_PORT}"
Even if I add the spring.cloud.vault.port=8200
property to the application-test.properties file I get the same exception.
So it seems that probably vault isn’t considering the application-test.properties file at all.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:20 (7 by maintainers)
Top GitHub Comments
I am using
3.0.4
and it still is not picking upapplication-{env}.yml
files to loadspring.cloud.vault.*
configurationsThanks for the details. Let me investigate what’s going on and come back to you.