0

I have a Spring Boot Application and I would like to Load configurations from Vault based on the Profile I am running. At present i have 2 profiles (dev, prod). My Dev Profile uses a H2 database where as the Prod Profile uses a Posgres DB. Running the dev Profile loads the correct config from Vault but running with the Prod Profile seems to be skipping it somehow and not looking in Vault.

bootstrap.yaml

spring:
  application:
    name: my-app
  profiles:
    active:
  cloud:
    vault:
      host: localhost
      port: 8200
      scheme: http
      uri: http://localhost:8200
      connection-timeout: 5000
      read-timeout: 15000
      authentication: TOKEN
      token: 00000000-0000-0000-0000-000000000000
      kv:
        enabled: true
        backend: secret
        default-context: my-app/dev
      fail-fast: false

bootstrap-prod.yaml

spring:
  application:
    name: gateway
  profiles:
    active: prod
  cloud:
    vault:
      host: localhost
      port: 8200
      scheme: http
      uri: http://localhost:8200
      connection-timeout: 5000
      read-timeout: 15000
      authentication: TOKEN
      token: 00000000-0000-0000-0000-000000000000
      kv:
        enabled: true
        backend: secret
        default-context: my-app/dev
      fail-fast: false

For example running the command gradle will load configuration from vault. But running gradle -Pprod fails to load the correct configuration from Vault.

MSRahman
  • 79
  • 2
  • 13

1 Answers1

0

try this syntax to activate your profile when using gradle:

./gradlew clean bootRun --args='--spring.profiles.active=prod'