attachDisk method
Attaches a block storage disk to a running or stopped Lightsail instance and exposes it to the instance with the specified disk name.
The attach disk
operation supports tag-based access control
via resource tags applied to the resource identified by disk
name
. For more information, see the Lightsail
Dev Guide.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.
Parameter diskName
:
The unique Lightsail disk name (e.g., my-disk
).
Parameter diskPath
:
The disk path to expose to the instance (e.g., /dev/xvdf
).
Parameter instanceName
:
The name of the Lightsail instance where you want to utilize the storage
disk.
Implementation
Future<AttachDiskResult> attachDisk({
required String diskName,
required String diskPath,
required String instanceName,
}) async {
ArgumentError.checkNotNull(diskName, 'diskName');
ArgumentError.checkNotNull(diskPath, 'diskPath');
ArgumentError.checkNotNull(instanceName, 'instanceName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.AttachDisk'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'diskName': diskName,
'diskPath': diskPath,
'instanceName': instanceName,
},
);
return AttachDiskResult.fromJson(jsonResponse.body);
}