func fetchAvailabilityZone() (string, error) {
	var err error
	var availabilityZone string

	// trying to get region from managed instance registration
	if availabilityZone = managedInstance.AvailabilityZone(); availabilityZone != "" {
		return availabilityZone, nil
	}

	// trying to get instance id from ec2 metadata
	if availabilityZone, err = metadata.GetMetadata("placement/availability-zone"); availabilityZone != "" && err == nil {
		return availabilityZone, nil
	}

	// trying to get region from dynamic data
	if availabilityZone, err = dynamicData.Region(); availabilityZone != "" && err == nil {
		return availabilityZone, nil
	}

	// return combined error messages
	return "", fmt.Errorf(errorMessage, "availability zone", err)
}
// fetchAvailabilityZone fetches the  availability zone with the following preference order.
// 1. managed instance registration
// 2. EC2 Instance Metadata
// 3. EC2 Instance Dynamic Data
fetchAvailabilityZone fetches the  availability zone with the following preference order.
1. managed instance registration
2. EC2 Instance Metadata
3. EC2 Instance Dynamic Data
// fetchAvailabilityZone fetches the availability zone with the following preference order . // 1 . managed instance registration // 2 . EC2 Instance Metadata // 3 . EC2 Instance Dynamic Data
func fetchAvailabilityZone() (string, error) {
	var err error
	var availabilityZone string
	if availabilityZone = managedInstance.AvailabilityZone(); availabilityZone != "" {
		return availabilityZone, nil
	}
	if availabilityZone, err = metadata.GetMetadata("placement/availability-zone"); availabilityZone != "" && err == nil {
		return availabilityZone, nil
	}
	if availabilityZone, err = dynamicData.Region(); availabilityZone != "" && err == nil {
		return availabilityZone, nil
	}
	return "", fmt.Errorf(errorMessage, "availability zone", err)
}
func fetchAvailabilityZone ( ) ( string , error ) { var err error var availabilityZone string if availabilityZone = managedInstance . AvailabilityZone ( ) ; availabilityZone != " " { return availabilityZone , nil } if availabilityZone , err = metadata . GetMetadata ( " " ) ; availabilityZone != " " && err == nil { return availabilityZone , nil } if availabilityZone , err = dynamicData . Region ( ) ; availabilityZone != " " && err == nil { return availabilityZone , nil } return " " , fmt . Errorf ( errorMessage , " " , err ) }
fetchAvailabilityZone fetches the  availability zone with the following preference order.
fetchAvailabilityZone fetches the availability zone with the following preference order .
// trying to get region from managed instance registration // trying to get instance id from ec2 metadata // trying to get region from dynamic data // return combined error messages