detach_volume
async
¶
detach_volume(
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
device: Optional[String] = None,
force: Optional[Boolean] = None,
instance_id: Optional[InstanceIdForResolver] = None,
volume_id: Optional[VolumeIdWithResolver] = None,
dry_run: Optional[Boolean] = None,
) -> VolumeAttachment
Detaches an EBS volume from an instance. Make sure to unmount any file systems on the device within your operating system before detaching the volume. Failure to do so can result in the volume becoming stuck in the busy state while detaching. If this happens, detachment can be delayed indefinitely until you unmount the volume, force detachment, reboot the instance, or all three. If an EBS volume is the root device of an instance, it can't be detached while the instance is running. To detach the root volume, stop the instance first.
When a volume with an Amazon Web Services Marketplace product code is detached from an instance, the product code is no longer associated with the instance.
You can't detach or force detach volumes that are attached to Amazon Web Services-managed resources. Attempting to do this results in the UnsupportedOperationException exception.
For more information, see Detach an Amazon EBS volume in the Amazon EBS User Guide.
Parameters:
-
device(Optional[String], default:None) –The device name.
-
force(Optional[Boolean], default:None) –Forces detachment if the previous detachment attempt did not occur cleanly (for example, logging into an instance, unmounting the volume, and detaching normally). This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance won't have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.
-
instance_id(Optional[InstanceIdForResolver], default:None) –The ID of the instance. If you are detaching a Multi-Attach enabled volume, you must specify an instance ID.
-
volume_id(Optional[VolumeIdWithResolver], default:None) –The ID of the volume.
-
dry_run(Optional[Boolean], default:None) –Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is
DryRunOperation. Otherwise, it isUnauthorizedOperation.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To detach a volume from an instance
This example detaches the volume (vol-049df61146c4d7901) from the instance it is attached to.
Source code in docs_src/capo_ec2/_services/async_ec2.py
38982 38983 38984 38985 38986 38987 38988 38989 38990 38991 38992 38993 38994 38995 38996 38997 38998 38999 39000 39001 39002 39003 39004 39005 39006 39007 39008 39009 39010 39011 39012 39013 39014 39015 39016 39017 39018 39019 39020 39021 39022 39023 39024 39025 39026 39027 39028 39029 39030 39031 39032 39033 39034 39035 39036 39037 39038 39039 39040 39041 39042 39043 39044 39045 39046 39047 39048 39049 39050 39051 | |