{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Network.AWS.EC2.DetachVolume -- Copyright : (c) 2013-2015 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- 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 results in the volume being stuck in a busy -- state while detaching. -- -- If an Amazon 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 AWS Marketplace product code is detached from an -- instance, the product code is no longer associated with the instance. -- -- For more information, see -- -- in the /Amazon Elastic Compute Cloud User Guide/. -- -- /See:/ for DetachVolume. module Network.AWS.EC2.DetachVolume ( -- * Creating a Request detachVolume , DetachVolume -- * Request Lenses , dvInstanceId , dvForce , dvDevice , dvDryRun , dvVolumeId -- * Destructuring the Response , volumeAttachment , VolumeAttachment -- * Response Lenses , volInstanceId , volDeleteOnTermination , volState , volDevice , volVolumeId , volAttachTime ) where import Network.AWS.EC2.Types import Network.AWS.EC2.Types.Product import Network.AWS.Prelude import Network.AWS.Request import Network.AWS.Response -- | /See:/ 'detachVolume' smart constructor. data DetachVolume = DetachVolume' { _dvInstanceId :: !(Maybe Text) , _dvForce :: !(Maybe Bool) , _dvDevice :: !(Maybe Text) , _dvDryRun :: !(Maybe Bool) , _dvVolumeId :: !Text } deriving (Eq,Read,Show,Data,Typeable,Generic) -- | Creates a value of 'DetachVolume' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'dvInstanceId' -- -- * 'dvForce' -- -- * 'dvDevice' -- -- * 'dvDryRun' -- -- * 'dvVolumeId' detachVolume :: Text -- ^ 'dvVolumeId' -> DetachVolume detachVolume pVolumeId_ = DetachVolume' { _dvInstanceId = Nothing , _dvForce = Nothing , _dvDevice = Nothing , _dvDryRun = Nothing , _dvVolumeId = pVolumeId_ } -- | The ID of the instance. dvInstanceId :: Lens' DetachVolume (Maybe Text) dvInstanceId = lens _dvInstanceId (\ s a -> s{_dvInstanceId = a}); -- | 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. dvForce :: Lens' DetachVolume (Maybe Bool) dvForce = lens _dvForce (\ s a -> s{_dvForce = a}); -- | The device name. dvDevice :: Lens' DetachVolume (Maybe Text) dvDevice = lens _dvDevice (\ s a -> s{_dvDevice = a}); -- | 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 is 'UnauthorizedOperation'. dvDryRun :: Lens' DetachVolume (Maybe Bool) dvDryRun = lens _dvDryRun (\ s a -> s{_dvDryRun = a}); -- | The ID of the volume. dvVolumeId :: Lens' DetachVolume Text dvVolumeId = lens _dvVolumeId (\ s a -> s{_dvVolumeId = a}); instance AWSRequest DetachVolume where type Sv DetachVolume = EC2 type Rs DetachVolume = VolumeAttachment request = post response = receiveXML (\ s h x -> parseXML x) instance ToHeaders DetachVolume where toHeaders = const mempty instance ToPath DetachVolume where toPath = const "/" instance ToQuery DetachVolume where toQuery DetachVolume'{..} = mconcat ["Action" =: ("DetachVolume" :: ByteString), "Version" =: ("2015-04-15" :: ByteString), "InstanceId" =: _dvInstanceId, "Force" =: _dvForce, "Device" =: _dvDevice, "DryRun" =: _dvDryRun, "VolumeId" =: _dvVolumeId]