-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openchallenges): make Eureka instance AWS-aware (IT-3800) (#2749)
- Loading branch information
1 parent
2c52dde
commit 0ac34b5
Showing
9 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
SERVER_PORT=8081 | ||
DEFAULT_ZONE=http://localhost:8081/eureka | ||
DEFAULT_ZONE=http://localhost:8081/eureka | ||
OPENCHALLENGES_SERVICE_REGISTRY_IS_DEPLOYED_ON_AWS=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
openchallenges-service-registry: | ||
welcome-message: 'Welcome to the service registry (local config).' | ||
is-deployed-on-aws: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
openchallengesVersion=0.0.1-SNAPSHOT | ||
spotlessVersion=6.11.0 | ||
springBootVersion=2.7.8 | ||
springCloudVersion=3.1.4 | ||
springDependencyManagementVersion=1.0.14.RELEASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ionetworks/openchallenges/service/registry/configuration/EurekaInstanceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.sagebionetworks.openchallenges.service.registry.configuration; | ||
|
||
import com.netflix.appinfo.AmazonInfo; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.cloud.commons.util.InetUtils; | ||
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class EurekaInstanceConfiguration { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(EurekaInstanceConfiguration.class); | ||
|
||
/** | ||
* If the application is planned to be deployed to an AWS cloud, the Eureka instance must be | ||
* configured to be AWS-aware. This can be done by customizing the EurekaInstanceConfigBean. | ||
* | ||
* @see <a | ||
* href="https://docs.spring.io/spring-cloud-netflix/docs/current/reference/html/#using-eureka-on-aws">Using | ||
* Eureka on AWS</a> | ||
*/ | ||
@Bean | ||
@ConditionalOnProperty( | ||
value = "openchallenges-service-registry.is-deployed-on-aws", | ||
havingValue = "true", | ||
matchIfMissing = false) | ||
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) { | ||
LOGGER.info("Configuring the Eureka instance to be AWS-aware."); | ||
EurekaInstanceConfigBean bean = new EurekaInstanceConfigBean(inetUtils); | ||
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka"); | ||
bean.setDataCenterInfo(info); | ||
return bean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ | |
public class ServiceRegistryConfigData { | ||
|
||
private String welcomeMessage; | ||
private boolean isDeployedOnAws; | ||
} |