assignVolume method

Future<void> assignVolume({
  1. required String volumeId,
  2. String? instanceId,
})

Assigns one of the stack's registered Amazon EBS volumes to a specified instance. The volume must first be registered with the stack by calling RegisterVolume. After you register the volume, you must call UpdateVolume to specify a mount point before calling AssignVolume. For more information, see Resource Management.

Required Permissions: To use this action, an IAM user must have a Manage permissions level for the stack, or an attached policy that explicitly grants permissions. For more information on user permissions, see Managing User Permissions.

May throw ValidationException. May throw ResourceNotFoundException.

Parameter volumeId : The volume ID.

Parameter instanceId : The instance ID.

Implementation

Future<void> assignVolume({
  required String volumeId,
  String? instanceId,
}) async {
  ArgumentError.checkNotNull(volumeId, 'volumeId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'OpsWorks_20130218.AssignVolume'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'VolumeId': volumeId,
      if (instanceId != null) 'InstanceId': instanceId,
    },
  );
}