question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vault isn't considering profile-specific files

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
dragneelfpscommented, Oct 9, 2021

I am using 3.0.4 and it still is not picking up application-{env}.yml files to load spring.cloud.vault.* configurations

2reactions
mp911decommented, Sep 27, 2021

Thanks for the details. Let me investigate what’s going on and come back to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use operators to refine a search in Vault - Google Help
For most services, Vault assumes there is an AND operator between search terms if no Boolean operator is specified. Vault ignores punctuation marks...
Read more >
java - bootstrap.yml configuration not processed anymore with ...
I moved vault config to application.yml file and you can see it here github.com/pavankjadda/HashiCorpVault-SpringCloud/blob/master/…. Am I doing ...
Read more >
24. Externalized Configuration - Spring
Files specified in spring.config.location are used as-is, with no support for profile-specific variants, and are overridden by any profile-specific properties.
Read more >
Use FileVault to encrypt your Mac startup disk - Apple Support
Turn FileVault on or off. When FileVault is turned on, your Mac requires your user account password to unlock your built-in startup disk...
Read more >
Enabling automatic restart of ID file synchronization
When Notes client ID vault synchronization fails because of mismatched passwords, the mismatch is flagged in the user's ID vault document. · If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found