createAccessKey method

Future<CreateAccessKeyResponse> createAccessKey({
  1. String? userName,
})

Creates a new AWS secret access key and corresponding AWS access key ID for the specified user. The default status for new keys is Active.

If you do not specify a user name, IAM determines the user name implicitly based on the AWS access key ID signing the request. This operation works for access keys under the AWS account. Consequently, you can use this operation to manage AWS account root user credentials. This is true even if the AWS account has no associated users.

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 NoSuchEntityException. May throw LimitExceededException. May throw ServiceFailureException.

Parameter userName : The name of the IAM user that the new key will belong to.

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: _+=,.@-

Implementation

Future<CreateAccessKeyResponse> createAccessKey({
  String? userName,
}) async {
  _s.validateStringLength(
    'userName',
    userName,
    1,
    128,
  );
  final $request = <String, dynamic>{};
  userName?.also((arg) => $request['UserName'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'CreateAccessKey',
    version: '2010-05-08',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['CreateAccessKeyRequest'],
    shapes: shapes,
    resultWrapper: 'CreateAccessKeyResult',
  );
  return CreateAccessKeyResponse.fromXml($result);
}