def set_location
      # Response format: "projects/<number>/zones/<zone>"
      @zone ||= fetch_gce_metadata('instance/zone').rpartition('/')[2] if
        @platform == Platform::GCE
      aws_location_key = if @use_aws_availability_zone
                           'availabilityZone'
                         else
                           'region'
                         end
      @zone ||= 'aws:' + ec2_metadata[aws_location_key] if
        @platform == Platform::EC2 && ec2_metadata.key?(aws_location_key)
    rescue StandardError => e
      @log.error 'Failed to obtain location: ', error: e
    end
def set_location
      # Response format: "projects/<number>/zones/<zone>"
      @zone ||= fetch_gce_metadata('instance/zone').rpartition('/')[2] if
        @platform == Platform::GCE
      aws_location_key = if @use_aws_availability_zone
                           'availabilityZone'
                         else
                           'region'
                         end
      @zone ||= 'aws:' + ec2_metadata[aws_location_key] if
        @platform == Platform::EC2 && ec2_metadata.key?(aws_location_key)
    rescue StandardError => e
      @log.error 'Failed to obtain location: ', error: e
    end
1. Return the value if it is explicitly set in the config already.
 2. If not, try to retrieve it locally.