createVirtualMFADevice method

Future<CreateVirtualMFADeviceResponse> createVirtualMFADevice({
  1. required String virtualMFADeviceName,
  2. String? path,
})

Creates a new virtual MFA device for the AWS account. After creating the virtual MFA, use EnableMFADevice to attach the MFA device to an IAM user. For more information about creating and working with virtual MFA devices, go to Using a Virtual MFA Device in the IAM User Guide.

The number and size of IAM resources in an AWS account are limited. For more information, see IAM and STS Quotas in the IAM User Guide.

May throw LimitExceededException. May throw EntityAlreadyExistsException. May throw ServiceFailureException.

Parameter virtualMFADeviceName : The name of the virtual MFA device. Use with path to uniquely identify a virtual MFA device.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Parameter path : The path for the virtual MFA device. For more information about paths, see IAM Identifiers in the IAM User Guide.

This parameter is optional. If it is not included, it defaults to a slash (/).

This parameter allows (through its regex pattern) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercased letters.

Implementation

Future<CreateVirtualMFADeviceResponse> createVirtualMFADevice({
  required String virtualMFADeviceName,
  String? path,
}) async {
  ArgumentError.checkNotNull(virtualMFADeviceName, 'virtualMFADeviceName');
  _s.validateStringLength(
    'virtualMFADeviceName',
    virtualMFADeviceName,
    1,
    1152921504606846976,
    isRequired: true,
  );
  _s.validateStringLength(
    'path',
    path,
    1,
    512,
  );
  final $request = <String, dynamic>{};
  $request['VirtualMFADeviceName'] = virtualMFADeviceName;
  path?.also((arg) => $request['Path'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'CreateVirtualMFADevice',
    version: '2010-05-08',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['CreateVirtualMFADeviceRequest'],
    shapes: shapes,
    resultWrapper: 'CreateVirtualMFADeviceResult',
  );
  return CreateVirtualMFADeviceResponse.fromXml($result);
}