List of usage examples for com.amazonaws.util EC2MetadataUtils getData
public static String getData(String path, int tries)
From source file:org.springframework.cloud.aws.context.annotation.OnAwsCloudEnvironmentCondition.java
License:Apache License
@Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { if (isCloudEnvironment == null) { try {/*from w ww. j av a2 s. c om*/ isCloudEnvironment = EC2MetadataUtils.getData(EC2_METADATA_ROOT + "/instance-id", 1) != null; } catch (AmazonClientException e) { isCloudEnvironment = false; } } return isCloudEnvironment; }
From source file:org.springframework.cloud.aws.context.support.env.AwsCloudEnvironmentCheckUtils.java
License:Apache License
public static boolean isRunningOnCloudEnvironment() { if (isCloudEnvironment == null) { try {/*from ww w. j a v a 2 s .com*/ isCloudEnvironment = EC2MetadataUtils.getData(EC2_METADATA_ROOT + "/instance-id", 1) != null; } catch (AmazonClientException e) { isCloudEnvironment = false; } } return isCloudEnvironment; }