0

I am creating spring-boot Eureka server and client micro-services to deploy on aws. I have read on tutorials that I have to define eureka.datacenter: cloud in my application.yml of eureka server so that it knows it is on aws. But when I try to use it in my application.yml file I get unknown property 'eureka.datacenter'. Dependencies I have included for eureka server.

 <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka-server</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-config</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
            </dependency>

        </dependencies>

I am using Spring boot 1.5.8.RELEASE and spring cloud Edgware.SR1.

Is eureka.datacenter property included in different version of spring cloud?

application.yml

spring:
  application:
    name: eureka-svc

---
spring:
  profiles: localhost
server:
  port: 8761
eureka:
  instance:
    hostname: localhost
  client:   
    fetchRegistry: false
    register-with-eureka: false
    serviceUrl:
      defaultZone: http://localhost:8761/eureka
---
spring:
  profiles: aws
server:
  port: 8761 
eureka:
  instance:
    non-secure-port: ${server.port}
    environment: production
  client:
    region: region
    register-with-eureka: true
    fetchRegistry: true
    use-dns-for-fetching-service-urls: true
    eureka-server-d-n-s-name: dns-name
    eureka-server-port: 8761
    eureka-server-u-r-l-context: eureka
  server:
    a-w-s-access-id: access-id
    a-w-s-secret-key: aws-key
    binding-strategy: route53
    list-auto-scaling-groups-role-name: role-name
anujprashar
  • 6,263
  • 7
  • 52
  • 86

3 Answers3

0

Don't you have to pass the eureka.datacenter as a commandline property?

Configuring Eureka

If you are running in the cloud environment, you will need to pass in the java commandline property -Deureka.datacenter=cloud so that the Eureka Client/Server knows to initialize the information specific to AWS cloud.

pan
  • 1,899
  • 1
  • 16
  • 24
  • yes I know that but on some posts online it was mention in .yml file. https://stackoverflow.com/questions/33659412/setting-up-eureka-for-non-aws-datacenter https://github.com/spring-cloud/spring-cloud-netflix/issues/791 – anujprashar Apr 11 '18 at 08:46
0

I'm following the instructions from

https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#_using_eureka_on_aws

@EnableEurekaServer
@SpringBootApplication
public class DiscoveryServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(DiscoveryServiceApplication.class, args);
    }

    @Bean
    @Profile("aws")
    public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
        EurekaInstanceConfigBean b = new EurekaInstanceConfigBean(inetUtils);
        AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
        b.setDataCenterInfo(info);
        return b;
    }

}
denov
  • 11,180
  • 2
  • 27
  • 43
-1

Might not make a difference but could you try:

eureka.datacenter: cloud

instead of:

eureka.datacenter=cloud

ootero
  • 3,235
  • 2
  • 16
  • 22
  • I did typing mistake while posting question. I did use eureka.datacenter: cloud. Sorry about that. I will edit question. – anujprashar Apr 10 '18 at 15:29