public static Region getCurrentRegion() {
        try {
            final String region = EC2MetadataUtils.getEC2InstanceRegion();
            if (region != null)
                return RegionUtils.getRegion(region);
        } catch (AmazonClientException e) {
            LogFactory.getLog(Regions.class).debug(
                "Ignoring failure to retrieve the region: " + e.getMessage());
        }
        return null;
    }
Returns a Region object representing the region the application is
running in, when running in EC2. If this method is called from a non-EC2
environment, it will return null.
aws-java-sdk-core/src/main/java/com/amazonaws/regions/Regions.java