I have a config server setup to read property files from a git library. I have also setup config client to use the property files from this server. I have also dockerized both these services running in EC2. All works perfectly in local environment.

In EC2, both the services start up and even config client is able to CURL the config server properties as expected. However, when an Environment variable tries to read the property in the config client program, the property value is not being read.

Below are my configurations:

Config server:

spring:
  application:
    name: config-server-services
  security:
    filter:
      order: 5
  cloud:
    bootstrap:
      enabled: true
    config:
      server:
        bootstrap: true
        native:
          search-locations: /tmp/git-repo
        git:
          default-label: main
          uri: https://XXXXXXXX:[email protected]/boxfile-suite/config-repo.git
          username: XXXXXXXXXXXXXXXXXXXX
          password: XXXXXXXXXXXXXXX
          clone-on-start: true
          skip-ssl-validation: true
          baseDir: /tmp/git-repo
  management:
    security:
      enabled: false

server:
  port: 8888

management:
  endpoints:
    web:
      exposure:
        include: "*"

logging:
  level:
    org.springframework: INFO

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: ${EUREKA_SERVER:http://localhost:8101/discovery-services/eureka}

  instance:
    status-page-url-path: /actuator/health
    health-check-url-path: /actuator/health
    instance-id: ${spring.application.name}:${random.value}

Config client:

spring:
  config.activate.on-profile: aws-devin
  cloud:
    bootstrap:
      enabled: true
    config:
      name: config-client
      uri: http://99.99.99.99:8888
      label: main
      profile: aws-devin, aws-devin-en-IN, aws-devin-en-AU, aws-devin-en-UK, aws-devin-en-US, aws-devin-en-UAE
  config:
    import: optional:configserver:http://99.99.99.99:8888
    use-legacy-processing: true

There were other challenges in bringing these services up. Fixed those issues and successfully able to curl config server properties from inside config client.

:~# docker exec -it config-client /bin/sh

# curl http://999.99.99.99:8888/config-client/aws-devin/main?IN.FEF19432-6F78-470B-AA1E-71538FA9B7F1.screenEntities

{"name":"config-client","profiles":["aws-devin"],"label":"main","version":"e3db94d5a1a80471db1d101d1a8bb43e036e3afe","state":null,"propertySources":[{"name":"https://XXXXXXXx:[email protected]/boxfile-suite/config-repo.git/config-client-aws-devin.yml%22,%22source%22:%7B%22FEF19432-6F78-470B-AA1E-71538FA9B7F1.tenant_customized%22:%22localhost%22,%22FEF19432-6F78-470B-AA1E-71538FA9B7F1.localhost.IN.screenEntities%22:%22client%22,%22

However, when the same is accessed via api in the config client application the property is not being read.

@Service
public class ConfigService {
    @Autowired
    private Environment env;

    .......

    log.debug("Trying to fetch the property: " + isoCode+"."+appCode+"."+"screenEntities" );
    String screenEntitiesDefault = env.getProperty(isoCode+"."+appCode+"."+"screenEntities");

The above property which I am trying to access via program is reflecting in the CURL output with the value from the git repo maintained by the config server.

Could any one of you direct me on what is possibly being overlooked?

0

There are 0 best solutions below