createInstance method

Future<CreateInstanceResponse> createInstance({
  1. String? clientToken,
  2. String? name,
  3. List<Tag>? tags,
})

Creates an instance of IAM Identity Center for a standalone Amazon Web Services account that is not managed by Organizations or a member Amazon Web Services account in an organization. You can create only one instance per account and across all Amazon Web Services Regions.

The CreateInstance request is rejected if the following apply:

  • The instance is created within the organization management account.
  • An instance already exists in the same account.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter clientToken : Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value.

If you don't provide this value, then Amazon Web Services generates a random one for you.

If you retry the operation with the same ClientToken, but with different parameters, the retry fails with an IdempotentParameterMismatch error.

Parameter name : The name of the instance of IAM Identity Center.

Parameter tags : Specifies tags to be attached to the instance of IAM Identity Center.

Implementation

Future<CreateInstanceResponse> createInstance({
  String? clientToken,
  String? name,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'SWBExternalService.CreateInstance'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (name != null) 'Name': name,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateInstanceResponse.fromJson(jsonResponse.body);
}