Skip to content
v2.274.0

DatabaseClusterProps Struct ​

Properties for a new database cluster.

Example ​

ts
declare const vpc: ec2.Vpc;
const cluster = new docdb.DatabaseCluster(this, 'Database', {
  masterUser: {
    username: 'myuser',
  },
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.MEMORY5, ec2.InstanceSize.LARGE),
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
  vpc,
  deletionProtection: true, // Enable deletion protection.
});

Properties ​

backupoptionalBackupPropsbackupoptionalBackupPropsbackupoptionalBackupPropsBackupoptionalBackupPropsBackupoptionalBackupProps#
Backup settings.

Default: Backup retention period for automated backups is 1 day. Backup preferred window is set to a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

caCertificateoptionalCaCertificateca_certificateoptionalCaCertificatecaCertificateoptionalCaCertificateCaCertificateoptionalCaCertificateCaCertificateoptionalCaCertificate#
The identifier of the CA certificate used for the instances.

Default: DocumentDB will choose a certificate authority

Specifying or updating this property triggers a reboot.

cloudWatchLogsRetentionoptionalRetentionDayscloud_watch_logs_retentionoptionalRetentionDayscloudWatchLogsRetentionoptionalRetentionDaysCloudWatchLogsRetentionoptionalRetentionDaysCloudWatchLogsRetentionoptionalRetentionDays#
The number of days log events are kept in CloudWatch Logs.

Default: logs never expire

When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to Infinity.

cloudWatchLogsRetentionRoleoptionalIRolecloud_watch_logs_retention_roleoptionalIRolecloudWatchLogsRetentionRoleoptionalIRoleCloudWatchLogsRetentionRoleoptionalIRoleCloudWatchLogsRetentionRoleoptionalIRole#
The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

Default: a new role is created.

copyTagsToSnapshotoptionalbooleancopy_tags_to_snapshotoptionalboolcopyTagsToSnapshotoptionalBooleanCopyTagsToSnapshotoptionalboolCopyTagsToSnapshotoptional*bool= false#
Whether to copy tags to the snapshot when a snapshot is created.
dbClusterNameoptionalstringdb_cluster_nameoptionalstrdbClusterNameoptionalStringDbClusterNameoptionalstringDbClusterNameoptional*string#
An optional identifier for the cluster.

Default: A name is automatically generated.

deletionProtectionoptionalbooleandeletion_protectionoptionalbooldeletionProtectionoptionalBooleanDeletionProtectionoptionalboolDeletionProtectionoptional*bool= false#
Specifies whether this cluster can be deleted.

If deletionProtection is enabled, the cluster cannot be deleted unless it is modified and deletionProtection is disabled. deletionProtection protects clusters from being accidentally deleted.

enablePerformanceInsightsoptionalbooleanenable_performance_insightsoptionalboolenablePerformanceInsightsoptionalBooleanEnablePerformanceInsightsoptionalboolEnablePerformanceInsightsoptional*bool= false#
A value that indicates whether to enable Performance Insights for the instances in the DB Cluster.
engineVersionoptionalstringengine_versionoptionalstrengineVersionoptionalStringEngineVersionoptionalstringEngineVersionoptional*string#
What version of the database to start.

Default: the latest major version

exportAuditLogsToCloudWatchoptionalbooleanexport_audit_logs_to_cloud_watchoptionalboolexportAuditLogsToCloudWatchoptionalBooleanExportAuditLogsToCloudWatchoptionalboolExportAuditLogsToCloudWatchoptional*bool= false#
Whether the audit logs should be exported to CloudWatch.

Note that you also have to configure the audit log export in the Cluster's Parameter Group.

exportProfilerLogsToCloudWatchoptionalbooleanexport_profiler_logs_to_cloud_watchoptionalboolexportProfilerLogsToCloudWatchoptionalBooleanExportProfilerLogsToCloudWatchoptionalboolExportProfilerLogsToCloudWatchoptional*bool= false#
Whether the profiler logs should be exported to CloudWatch.

Note that you also have to configure the profiler log export in the Cluster's Parameter Group.

instanceIdentifierBaseoptionalstringinstance_identifier_baseoptionalstrinstanceIdentifierBaseoptionalStringInstanceIdentifierBaseoptionalstringInstanceIdentifierBaseoptional*string#
Base identifier for instances.

Default: dbClusterName is used with the word "Instance" appended. If dbClusterName is not provided, the identifier is automatically generated.

Every replica is named by appending the replica number to this string, 1-based. Only applicable for provisioned clusters.

instanceMaintenanceWindowoptionalstringinstance_maintenance_windowoptionalstrinstanceMaintenanceWindowoptionalStringInstanceMaintenanceWindowoptionalstringInstanceMaintenanceWindowoptional*string#
The weekly time range during which system maintenance can occur on the cluster's instances.

Default: a 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

notes

The cluster-level preferredMaintenanceWindow applies to cluster-wide maintenance events; this prop applies to each auto-created instance independently. To use the same window for both, set this prop to the same value as preferredMaintenanceWindow.

Format: ddd:hh24:mi-ddd:hh24:mi. Must be at least 30 minutes long. Example: 'sat:09:00-sat:09:30'

Only applicable to provisioned clusters; has no effect on serverless clusters because they do not create instances.

instanceRemovalPolicyoptionalRemovalPolicyinstance_removal_policyoptionalRemovalPolicyinstanceRemovalPolicyoptionalRemovalPolicyInstanceRemovalPolicyoptionalRemovalPolicyInstanceRemovalPolicyoptionalRemovalPolicy#
The removal policy to apply to the cluster's instances.

Default: RemovalPolicy.DESTROY when removalPolicy is set to SNAPSHOT, removalPolicy otherwise.

Cannot be set to SNAPSHOT.

instancesoptionalnumberinstancesoptionalint | floatinstancesoptionalNumberInstancesoptionaldoubleInstancesoptional*float64= 1#
Number of DocDB compute instances.
instanceTypeoptionalInstanceTypeinstance_typeoptionalInstanceTypeinstanceTypeoptionalInstanceTypeInstanceTypeoptionalInstanceTypeInstanceTypeoptionalInstanceType= None#
What type of instance to start for the replicas.

Required for provisioned clusters, not applicable for serverless clusters.

kmsKeyoptionalIKeykms_keyoptionalIKeykmsKeyoptionalIKeyKmsKeyoptionalIKeyKmsKeyoptionalIKey#
The KMS key for storage encryption.

Default: default master key.

manageMasterUserPasswordoptionalbooleanmanage_master_user_passwordoptionalboolmanageMasterUserPasswordoptionalBooleanManageMasterUserPasswordoptionalboolManageMasterUserPasswordoptional*bool= false#
Specifies whether to manage the master user password with AWS Secrets Manager.
notes

When set to true, Amazon DocumentDB will automatically generate and manage the master user password in AWS Secrets Manager. This provides enhanced security and automatic password rotation capabilities.

Constraint: You can't manage the master user password with AWS Secrets Manager if masterUser.password is specified.

The secret property of the cluster is not set when using this option. See the module README for how to access the managed secret.

masterUserLoginmaster_userLoginmasterUserLoginMasterUserLoginMasterUserLoginrequired#
Username and password for the administrative user.
masterUserSecretKmsKeyoptionalIKeymaster_user_secret_kms_keyoptionalIKeymasterUserSecretKmsKeyoptionalIKeyMasterUserSecretKmsKeyoptionalIKeyMasterUserSecretKmsKeyoptionalIKey#
The AWS KMS key to encrypt a secret that is automatically generated and managed in AWS Secrets Manager.

Default: default AWS managed key aws/secretsmanager

notes

This setting is valid only if the master user password is managed by Amazon DocumentDB in AWS Secrets Manager for the DB cluster (i.e. when manageMasterUserPassword is true). If you don't specify this property, then the aws/secretsmanager KMS key is used to encrypt the secret.

parameterGroupoptionalIDBClusterParameterGroupRefparameter_groupoptionalIDBClusterParameterGroupRefparameterGroupoptionalIDBClusterParameterGroupRefParameterGroupoptionalIDBClusterParameterGroupRefParameterGroupoptionalIDBClusterParameterGroupRef#
The DB parameter group to associate with the instance.

Default: no parameter group

portoptionalnumberportoptionalint | floatportoptionalNumberPortoptionaldoublePortoptional*float64= DatabaseCluster.DEFAULT_PORT#
The port the DocumentDB cluster will listen on.
preferredMaintenanceWindowoptionalstringpreferred_maintenance_windowoptionalstrpreferredMaintenanceWindowoptionalStringPreferredMaintenanceWindowoptionalstringPreferredMaintenanceWindowoptional*string#
A weekly time range in which maintenance should preferably execute.

Default: 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

Must be at least 30 minutes long.

Example: 'tue:04:17-tue:04:47'

removalPolicyoptionalRemovalPolicyremoval_policyoptionalRemovalPolicyremovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicy#
The removal policy to apply when the cluster and its instances are removed or replaced during a stack update, or when the stack is deleted.

Default: Retain cluster.

notes

This removal policy also applies to the implicit security group created for the cluster if one is not supplied as a parameter.

When set to SNAPSHOT, the removal policy for the instances and the security group will default to DESTROY as those resources do not support the policy.

Use the instanceRemovalPolicy and securityGroupRemovalPolicy to change the behavior.

securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroup#
Security group.

Default: a new security group is created.

securityGroupRemovalPolicyoptionalRemovalPolicysecurity_group_removal_policyoptionalRemovalPolicysecurityGroupRemovalPolicyoptionalRemovalPolicySecurityGroupRemovalPolicyoptionalRemovalPolicySecurityGroupRemovalPolicyoptionalRemovalPolicy#
The removal policy to apply to the cluster's security group.

Default: RemovalPolicy.DESTROY when removalPolicy is set to SNAPSHOT, removalPolicy otherwise.

Cannot be set to SNAPSHOT.

serverlessV2ScalingConfigurationoptionalServerlessV2ScalingConfigurationserverless_v2_scaling_configurationoptionalServerlessV2ScalingConfigurationserverlessV2ScalingConfigurationoptionalServerlessV2ScalingConfigurationServerlessV2ScalingConfigurationoptionalServerlessV2ScalingConfigurationServerlessV2ScalingConfigurationoptionalServerlessV2ScalingConfiguration= None#
ServerlessV2 scaling configuration.

When specified, the cluster will be created as a serverless cluster.

storageEncryptedoptionalbooleanstorage_encryptedoptionalboolstorageEncryptedoptionalBooleanStorageEncryptedoptionalboolStorageEncryptedoptional*bool= true#
Whether to enable storage encryption.
storageTypeoptionalStorageTypestorage_typeoptionalStorageTypestorageTypeoptionalStorageTypeStorageTypeoptionalStorageTypeStorageTypeoptionalStorageType= StorageType.STANDARD#
The storage type of the DocDB cluster.

I/O-optimized storage is supported starting with engine version 5.0.0.

vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
What subnets to run the DocumentDB instances in.

Must be at least 2 subnets in two different AZs.

vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection#
Where to place the instances within the VPC.

Default: private subnets