List of usage examples for com.amazonaws.util EC2MetadataUtils getAvailabilityZone
public static String getAvailabilityZone()
From source file:com.kixeye.chassis.bootstrap.aws.ServerInstanceContext.java
License:Apache License
private ServerInstanceContext() { amazonElasticLoadBalancing = new AmazonElasticLoadBalancingClient(); amazonEC2 = new AmazonEC2Client(); ec2MetadataClient = new Ec2MetadataClient() { @Override//w w w . j ava2 s.c o m public String getAvailabilityZone() { return EC2MetadataUtils.getAvailabilityZone(); } @Override public String getInstanceId() { return EC2MetadataUtils.getInstanceId(); } @Override public String getUserData() { return EC2MetadataUtils.getUserData(); } @Override public String getPrivateIpAddress() { return EC2MetadataUtils.getPrivateIpAddress(); } @Override public String getPublicIpAddress() { for (EC2MetadataUtils.NetworkInterface net : EC2MetadataUtils.getNetworkInterfaces()) { List<String> ips = net.getPublicIPv4s(); if (ips != null && ips.size() > 0) { return ips.get(0); } } return null; } }; init(); }
From source file:org.springframework.cloud.aws.support.profile.AmazonWebserviceProfileValueSource.java
License:Apache License
@Override public String get(String key) { if ("amazon-webservice-region-available".equals(key)) { return Boolean.toString(EC2MetadataUtils.getAvailabilityZone() != null); }// ww w .j av a 2s.c o m return null; }