createDBInstance method

Future<CreateDBInstanceResult> createDBInstance({
  1. required String dBClusterIdentifier,
  2. required String dBInstanceClass,
  3. required String dBInstanceIdentifier,
  4. required String engine,
  5. bool? autoMinorVersionUpgrade,
  6. String? availabilityZone,
  7. String? cACertificateIdentifier,
  8. bool? copyTagsToSnapshot,
  9. bool? enablePerformanceInsights,
  10. String? performanceInsightsKMSKeyId,
  11. String? preferredMaintenanceWindow,
  12. int? promotionTier,
  13. List<Tag>? tags,
})

Creates a new instance.

May throw AuthorizationNotFoundFault. May throw DBClusterNotFoundFault. May throw DBInstanceAlreadyExistsFault. May throw DBParameterGroupNotFoundFault. May throw DBSecurityGroupNotFoundFault. May throw DBSubnetGroupDoesNotCoverEnoughAZs. May throw DBSubnetGroupNotFoundFault. May throw InstanceQuotaExceededFault. May throw InsufficientDBInstanceCapacityFault. May throw InvalidDBClusterStateFault. May throw InvalidSubnet. May throw InvalidVPCNetworkStateFault. May throw KMSKeyNotAccessibleFault. May throw StorageQuotaExceededFault. May throw StorageTypeNotSupportedFault.

Parameter dBClusterIdentifier : The identifier of the cluster that the instance will belong to.

Parameter dBInstanceClass : The compute and memory capacity of the instance; for example, db.r5.large.

Parameter dBInstanceIdentifier : The instance identifier. This parameter is stored as a lowercase string.

Constraints:

  • Must contain from 1 to 63 letters, numbers, or hyphens.
  • The first character must be a letter.
  • Cannot end with a hyphen or contain two consecutive hyphens.
Example: mydbinstance

Parameter engine : The name of the database engine to be used for this instance.

Valid value: docdb

Parameter autoMinorVersionUpgrade : This parameter does not apply to Amazon DocumentDB. Amazon DocumentDB does not perform minor version upgrades regardless of the value set.

Default: false

Parameter availabilityZone : The Amazon EC2 Availability Zone that the instance is created in.

Default: A random, system-chosen Availability Zone in the endpoint's Amazon Web Services Region.

Example: us-east-1d

Parameter cACertificateIdentifier : The CA certificate identifier to use for the DB instance's server certificate.

For more information, see Updating Your Amazon DocumentDB TLS Certificates and Encrypting Data in Transit in the Amazon DocumentDB Developer Guide.

Parameter copyTagsToSnapshot : A value that indicates whether to copy tags from the DB instance to snapshots of the DB instance. By default, tags are not copied.

Parameter enablePerformanceInsights : A value that indicates whether to enable Performance Insights for the DB Instance. For more information, see Using Amazon Performance Insights.

Parameter performanceInsightsKMSKeyId : The KMS key identifier for encryption of Performance Insights data.

The KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key.

If you do not specify a value for PerformanceInsightsKMSKeyId, then Amazon DocumentDB uses your default KMS key. There is a default KMS key for your Amazon Web Services account. Your Amazon Web Services account has a different default KMS key for each Amazon Web Services region.

Parameter preferredMaintenanceWindow : The time range each week during which system maintenance can occur, in Universal Coordinated Time (UTC).

Format: ddd:hh24:mi-ddd:hh24:mi

The default is a 30-minute window selected at random from an 8-hour block of time for each Amazon Web Services Region, occurring on a random day of the week.

Valid days: Mon, Tue, Wed, Thu, Fri, Sat, Sun

Constraints: Minimum 30-minute window.

Parameter promotionTier : A value that specifies the order in which an Amazon DocumentDB replica is promoted to the primary instance after a failure of the existing primary instance.

Default: 1

Valid values: 0-15

Parameter tags : The tags to be assigned to the instance. You can assign up to 10 tags to an instance.

Implementation

Future<CreateDBInstanceResult> createDBInstance({
  required String dBClusterIdentifier,
  required String dBInstanceClass,
  required String dBInstanceIdentifier,
  required String engine,
  bool? autoMinorVersionUpgrade,
  String? availabilityZone,
  String? cACertificateIdentifier,
  bool? copyTagsToSnapshot,
  bool? enablePerformanceInsights,
  String? performanceInsightsKMSKeyId,
  String? preferredMaintenanceWindow,
  int? promotionTier,
  List<Tag>? tags,
}) async {
  final $request = <String, String>{
    'DBClusterIdentifier': dBClusterIdentifier,
    'DBInstanceClass': dBInstanceClass,
    'DBInstanceIdentifier': dBInstanceIdentifier,
    'Engine': engine,
    if (autoMinorVersionUpgrade != null)
      'AutoMinorVersionUpgrade': autoMinorVersionUpgrade.toString(),
    if (availabilityZone != null) 'AvailabilityZone': availabilityZone,
    if (cACertificateIdentifier != null)
      'CACertificateIdentifier': cACertificateIdentifier,
    if (copyTagsToSnapshot != null)
      'CopyTagsToSnapshot': copyTagsToSnapshot.toString(),
    if (enablePerformanceInsights != null)
      'EnablePerformanceInsights': enablePerformanceInsights.toString(),
    if (performanceInsightsKMSKeyId != null)
      'PerformanceInsightsKMSKeyId': performanceInsightsKMSKeyId,
    if (preferredMaintenanceWindow != null)
      'PreferredMaintenanceWindow': preferredMaintenanceWindow,
    if (promotionTier != null) 'PromotionTier': promotionTier.toString(),
    if (tags != null)
      if (tags.isEmpty)
        'Tags': ''
      else
        for (var i1 = 0; i1 < tags.length; i1++)
          for (var e3 in tags[i1].toQueryMap().entries)
            'Tags.Tag.${i1 + 1}.${e3.key}': e3.value,
  };
  final $result = await _protocol.send(
    $request,
    action: 'CreateDBInstance',
    version: '2014-10-31',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    resultWrapper: 'CreateDBInstanceResult',
  );
  return CreateDBInstanceResult.fromXml($result);
}