Class DatabaseInstance.Builder

java.lang.Object
software.amazon.awscdk.services.rds.DatabaseInstance.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<DatabaseInstance>
Enclosing class:
DatabaseInstance

@Stability(Stable) public static final class DatabaseInstance.Builder extends Object implements software.amazon.jsii.Builder<DatabaseInstance>
A fluent builder for DatabaseInstance.
  • Method Details

    • create

      @Stability(Stable) public static DatabaseInstance.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of DatabaseInstance.Builder.
    • vpc

      @Stability(Stable) public DatabaseInstance.Builder vpc(IVpc vpc)
      The VPC network where the DB subnet group should be created.

      Parameters:
      vpc - The VPC network where the DB subnet group should be created. This parameter is required.
      Returns:
      this
    • autoMinorVersionUpgrade

      @Stability(Stable) public DatabaseInstance.Builder autoMinorVersionUpgrade(Boolean autoMinorVersionUpgrade)
      Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window.

      Default: true

      Parameters:
      autoMinorVersionUpgrade - Indicates that minor engine upgrades are applied automatically to the DB instance during the maintenance window. This parameter is required.
      Returns:
      this
    • availabilityZone

      @Stability(Stable) public DatabaseInstance.Builder availabilityZone(String availabilityZone)
      The name of the Availability Zone where the DB instance will be located.

      Default: - no preference

      Parameters:
      availabilityZone - The name of the Availability Zone where the DB instance will be located. This parameter is required.
      Returns:
      this
    • backupRetention

      @Stability(Stable) public DatabaseInstance.Builder backupRetention(Duration backupRetention)
      The number of days during which automatic DB snapshots are retained.

      Set to zero to disable backups. When creating a read replica, you must enable automatic backups on the source database instance by setting the backup retention to a value other than zero.

      Default: - Duration.days(1) for source instances, disabled for read replicas

      Parameters:
      backupRetention - The number of days during which automatic DB snapshots are retained. This parameter is required.
      Returns:
      this
    • caCertificate

      @Stability(Stable) public DatabaseInstance.Builder caCertificate(CaCertificate caCertificate)
      The identifier of the CA certificate for this DB instance.

      Specifying or updating this property triggers a reboot.

      For RDS DB engines:

      Default: - RDS will choose a certificate authority

      Parameters:
      caCertificate - The identifier of the CA certificate for this DB instance. This parameter is required.
      Returns:
      this
      See Also:
    • cloudwatchLogsExports

      @Stability(Stable) public DatabaseInstance.Builder cloudwatchLogsExports(List<String> cloudwatchLogsExports)
      The list of log types that need to be enabled for exporting to CloudWatch Logs.

      Default: - no log exports

      Parameters:
      cloudwatchLogsExports - The list of log types that need to be enabled for exporting to CloudWatch Logs. This parameter is required.
      Returns:
      this
    • cloudwatchLogsRetention

      @Stability(Stable) public DatabaseInstance.Builder cloudwatchLogsRetention(RetentionDays cloudwatchLogsRetention)
      The number of days log events are kept in CloudWatch Logs.

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

      Default: - logs never expire

      Parameters:
      cloudwatchLogsRetention - The number of days log events are kept in CloudWatch Logs. This parameter is required.
      Returns:
      this
    • cloudwatchLogsRetentionRole

      @Stability(Stable) public DatabaseInstance.Builder cloudwatchLogsRetentionRole(IRole cloudwatchLogsRetentionRole)
      The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

      Default: - a new role is created.

      Parameters:
      cloudwatchLogsRetentionRole - The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This parameter is required.
      Returns:
      this
    • copyTagsToSnapshot

      @Stability(Stable) public DatabaseInstance.Builder copyTagsToSnapshot(Boolean copyTagsToSnapshot)
      Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance.

      Default: true

      Parameters:
      copyTagsToSnapshot - Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. This parameter is required.
      Returns:
      this
    • deleteAutomatedBackups

      @Stability(Stable) public DatabaseInstance.Builder deleteAutomatedBackups(Boolean deleteAutomatedBackups)
      Indicates whether automated backups should be deleted or retained when you delete a DB instance.

      Default: true

      Parameters:
      deleteAutomatedBackups - Indicates whether automated backups should be deleted or retained when you delete a DB instance. This parameter is required.
      Returns:
      this
    • deletionProtection

      @Stability(Stable) public DatabaseInstance.Builder deletionProtection(Boolean deletionProtection)
      Indicates whether the DB instance should have deletion protection enabled.

      Default: - true if ``removalPolicy`` is RETAIN, false otherwise

      Parameters:
      deletionProtection - Indicates whether the DB instance should have deletion protection enabled. This parameter is required.
      Returns:
      this
    • domain

      @Stability(Stable) public DatabaseInstance.Builder domain(String domain)
      The Active Directory directory ID to create the DB instance in.

      Default: - Do not join domain

      Parameters:
      domain - The Active Directory directory ID to create the DB instance in. This parameter is required.
      Returns:
      this
    • domainRole

      @Stability(Stable) public DatabaseInstance.Builder domainRole(IRole domainRole)
      The IAM role to be used when making API calls to the Directory Service.

      The role needs the AWS-managed policy AmazonRDSDirectoryServiceAccess or equivalent.

      Default: - The role will be created for you if `DatabaseInstanceNewProps#domain` is specified

      Parameters:
      domainRole - The IAM role to be used when making API calls to the Directory Service. This parameter is required.
      Returns:
      this
    • enablePerformanceInsights

      @Stability(Stable) public DatabaseInstance.Builder enablePerformanceInsights(Boolean enablePerformanceInsights)
      Whether to enable Performance Insights for the DB instance.

      Default: - false, unless ``performanceInsightRetention`` or ``performanceInsightEncryptionKey`` is set.

      Parameters:
      enablePerformanceInsights - Whether to enable Performance Insights for the DB instance. This parameter is required.
      Returns:
      this
    • iamAuthentication

      @Stability(Stable) public DatabaseInstance.Builder iamAuthentication(Boolean iamAuthentication)
      Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts.

      Default: false

      Parameters:
      iamAuthentication - Whether to enable mapping of AWS Identity and Access Management (IAM) accounts to database accounts. This parameter is required.
      Returns:
      this
    • instanceIdentifier

      @Stability(Stable) public DatabaseInstance.Builder instanceIdentifier(String instanceIdentifier)
      A name for the DB instance.

      If you specify a name, AWS CloudFormation converts it to lowercase.

      Default: - a CloudFormation generated name

      Parameters:
      instanceIdentifier - A name for the DB instance. This parameter is required.
      Returns:
      this
    • iops

      @Stability(Stable) public DatabaseInstance.Builder iops(Number iops)
      The number of I/O operations per second (IOPS) that the database provisions.

      The value must be equal to or greater than 1000.

      Default: - no provisioned iops if storage type is not specified. For GP3: 3,000 IOPS if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 12,000 IOPS otherwise (except for SQL Server where the default is always 3,000 IOPS).

      Parameters:
      iops - The number of I/O operations per second (IOPS) that the database provisions. This parameter is required.
      Returns:
      this
    • maxAllocatedStorage

      @Stability(Stable) public DatabaseInstance.Builder maxAllocatedStorage(Number maxAllocatedStorage)
      Upper limit to which RDS can scale the storage in GiB(Gibibyte).

      Default: - No autoscaling of RDS instance

      Parameters:
      maxAllocatedStorage - Upper limit to which RDS can scale the storage in GiB(Gibibyte). This parameter is required.
      Returns:
      this
      See Also:
    • monitoringInterval

      @Stability(Stable) public DatabaseInstance.Builder monitoringInterval(Duration monitoringInterval)
      The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instance.

      Default: - no enhanced monitoring

      Parameters:
      monitoringInterval - The interval, in seconds, between points when Amazon RDS collects enhanced monitoring metrics for the DB instance. This parameter is required.
      Returns:
      this
    • monitoringRole

      @Stability(Stable) public DatabaseInstance.Builder monitoringRole(IRole monitoringRole)
      Role that will be used to manage DB instance monitoring.

      Default: - A role is automatically created for you

      Parameters:
      monitoringRole - Role that will be used to manage DB instance monitoring. This parameter is required.
      Returns:
      this
    • multiAz

      @Stability(Stable) public DatabaseInstance.Builder multiAz(Boolean multiAz)
      Specifies if the database instance is a multiple Availability Zone deployment.

      Default: false

      Parameters:
      multiAz - Specifies if the database instance is a multiple Availability Zone deployment. This parameter is required.
      Returns:
      this
    • networkType

      @Stability(Stable) public DatabaseInstance.Builder networkType(NetworkType networkType)
      The network type of the DB instance.

      Default: - IPV4

      Parameters:
      networkType - The network type of the DB instance. This parameter is required.
      Returns:
      this
    • optionGroup

      @Stability(Stable) public DatabaseInstance.Builder optionGroup(IOptionGroup optionGroup)
      The option group to associate with the instance.

      Default: - no option group

      Parameters:
      optionGroup - The option group to associate with the instance. This parameter is required.
      Returns:
      this
    • parameterGroup

      @Stability(Stable) public DatabaseInstance.Builder parameterGroup(IParameterGroup parameterGroup)
      The DB parameter group to associate with the instance.

      Default: - no parameter group

      Parameters:
      parameterGroup - The DB parameter group to associate with the instance. This parameter is required.
      Returns:
      this
    • performanceInsightEncryptionKey

      @Stability(Stable) public DatabaseInstance.Builder performanceInsightEncryptionKey(IKey performanceInsightEncryptionKey)
      The AWS KMS key for encryption of Performance Insights data.

      Default: - default master key

      Parameters:
      performanceInsightEncryptionKey - The AWS KMS key for encryption of Performance Insights data. This parameter is required.
      Returns:
      this
    • performanceInsightRetention

      @Stability(Stable) public DatabaseInstance.Builder performanceInsightRetention(PerformanceInsightRetention performanceInsightRetention)
      The amount of time, in days, to retain Performance Insights data.

      Default: 7 this is the free tier

      Parameters:
      performanceInsightRetention - The amount of time, in days, to retain Performance Insights data. This parameter is required.
      Returns:
      this
    • port

      @Stability(Stable) public DatabaseInstance.Builder port(Number port)
      The port for the instance.

      Default: - the default port for the chosen engine.

      Parameters:
      port - The port for the instance. This parameter is required.
      Returns:
      this
    • preferredBackupWindow

      @Stability(Stable) public DatabaseInstance.Builder preferredBackupWindow(String preferredBackupWindow)
      The daily time range during which automated backups are performed.

      Constraints:

      • Must be in the format hh24:mi-hh24:mi.
      • Must be in Universal Coordinated Time (UTC).
      • Must not conflict with the preferred maintenance window.
      • Must be at least 30 minutes.

      Default: - a 30-minute window selected at random from an 8-hour block of time for each AWS Region. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html#USER_WorkingWithAutomatedBackups.BackupWindow

      Parameters:
      preferredBackupWindow - The daily time range during which automated backups are performed. This parameter is required.
      Returns:
      this
    • preferredMaintenanceWindow

      @Stability(Stable) public DatabaseInstance.Builder preferredMaintenanceWindow(String preferredMaintenanceWindow)
      The weekly time range (in UTC) during which system maintenance can occur.

      Format: ddd:hh24:mi-ddd:hh24:mi Constraint: Minimum 30-minute window

      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. To see the time blocks available, see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html#Concepts.DBMaintenance

      Parameters:
      preferredMaintenanceWindow - The weekly time range (in UTC) during which system maintenance can occur. This parameter is required.
      Returns:
      this
    • processorFeatures

      @Stability(Stable) public DatabaseInstance.Builder processorFeatures(ProcessorFeatures processorFeatures)
      The number of CPU cores and the number of threads per core.

      Default: - the default number of CPU cores and threads per core for the chosen instance class. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor

      Parameters:
      processorFeatures - The number of CPU cores and the number of threads per core. This parameter is required.
      Returns:
      this
    • publiclyAccessible

      @Stability(Stable) public DatabaseInstance.Builder publiclyAccessible(Boolean publiclyAccessible)
      Indicates whether the DB instance is an internet-facing instance.

      If not specified, the instance's vpcSubnets will be used to determine if the instance is internet-facing or not.

      Default: - `true` if the instance's `vpcSubnets` is `subnetType: SubnetType.PUBLIC`, `false` otherwise

      Parameters:
      publiclyAccessible - Indicates whether the DB instance is an internet-facing instance. This parameter is required.
      Returns:
      this
    • removalPolicy

      @Stability(Stable) public DatabaseInstance.Builder removalPolicy(RemovalPolicy removalPolicy)
      The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update.

      Default: - RemovalPolicy.SNAPSHOT (remove the resource, but retain a snapshot of the data)

      Parameters:
      removalPolicy - The CloudFormation policy to apply when the instance is removed from the stack or replaced during an update. This parameter is required.
      Returns:
      this
    • s3ExportBuckets

      @Stability(Stable) public DatabaseInstance.Builder s3ExportBuckets(List<? extends IBucket> s3ExportBuckets)
      S3 buckets that you want to load data into.

      This property must not be used if s3ExportRole is used.

      For Microsoft SQL Server:

      Default: - None

      Parameters:
      s3ExportBuckets - S3 buckets that you want to load data into. This parameter is required.
      Returns:
      this
      See Also:
    • s3ExportRole

      @Stability(Stable) public DatabaseInstance.Builder s3ExportRole(IRole s3ExportRole)
      Role that will be associated with this DB instance to enable S3 export.

      This property must not be used if s3ExportBuckets is used.

      For Microsoft SQL Server:

      Default: - New role is created if `s3ExportBuckets` is set, no role is defined otherwise

      Parameters:
      s3ExportRole - Role that will be associated with this DB instance to enable S3 export. This parameter is required.
      Returns:
      this
      See Also:
    • s3ImportBuckets

      @Stability(Stable) public DatabaseInstance.Builder s3ImportBuckets(List<? extends IBucket> s3ImportBuckets)
      S3 buckets that you want to load data from.

      This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines.

      This property must not be used if s3ImportRole is used.

      For Microsoft SQL Server:

      Default: - None

      Parameters:
      s3ImportBuckets - S3 buckets that you want to load data from. This parameter is required.
      Returns:
      this
      See Also:
    • s3ImportRole

      @Stability(Stable) public DatabaseInstance.Builder s3ImportRole(IRole s3ImportRole)
      Role that will be associated with this DB instance to enable S3 import.

      This feature is only supported by the Microsoft SQL Server, Oracle, and PostgreSQL engines.

      This property must not be used if s3ImportBuckets is used.

      For Microsoft SQL Server:

      Default: - New role is created if `s3ImportBuckets` is set, no role is defined otherwise

      Parameters:
      s3ImportRole - Role that will be associated with this DB instance to enable S3 import. This parameter is required.
      Returns:
      this
      See Also:
    • securityGroups

      @Stability(Stable) public DatabaseInstance.Builder securityGroups(List<? extends ISecurityGroup> securityGroups)
      The security groups to assign to the DB instance.

      Default: - a new security group is created

      Parameters:
      securityGroups - The security groups to assign to the DB instance. This parameter is required.
      Returns:
      this
    • storageThroughput

      @Stability(Stable) public DatabaseInstance.Builder storageThroughput(Number storageThroughput)
      The storage throughput, specified in mebibytes per second (MiBps).

      Only applicable for GP3.

      Default: - 125 MiBps if allocated storage is less than 400 GiB for MariaDB, MySQL, and PostgreSQL, less than 200 GiB for Oracle and less than 20 GiB for SQL Server. 500 MiBps otherwise (except for SQL Server where the default is always 125 MiBps).

      Parameters:
      storageThroughput - The storage throughput, specified in mebibytes per second (MiBps). This parameter is required.
      Returns:
      this
      See Also:
    • storageType

      @Stability(Stable) public DatabaseInstance.Builder storageType(StorageType storageType)
      The storage type.

      Storage types supported are gp2, io1, standard.

      Default: GP2

      Parameters:
      storageType - The storage type. This parameter is required.
      Returns:
      this
      See Also:
    • subnetGroup

      @Stability(Stable) public DatabaseInstance.Builder subnetGroup(ISubnetGroup subnetGroup)
      Existing subnet group for the instance.

      Default: - a new subnet group will be created.

      Parameters:
      subnetGroup - Existing subnet group for the instance. This parameter is required.
      Returns:
      this
    • vpcSubnets

      @Stability(Stable) public DatabaseInstance.Builder vpcSubnets(SubnetSelection vpcSubnets)
      The type of subnets to add to the created DB subnet group.

      Default: - private subnets

      Parameters:
      vpcSubnets - The type of subnets to add to the created DB subnet group. This parameter is required.
      Returns:
      this
    • engine

      @Stability(Stable) public DatabaseInstance.Builder engine(IInstanceEngine engine)
      The database engine.

      Parameters:
      engine - The database engine. This parameter is required.
      Returns:
      this
    • allocatedStorage

      @Stability(Stable) public DatabaseInstance.Builder allocatedStorage(Number allocatedStorage)
      The allocated storage size, specified in gibibytes (GiB).

      Default: 100

      Parameters:
      allocatedStorage - The allocated storage size, specified in gibibytes (GiB). This parameter is required.
      Returns:
      this
    • allowMajorVersionUpgrade

      @Stability(Stable) public DatabaseInstance.Builder allowMajorVersionUpgrade(Boolean allowMajorVersionUpgrade)
      Whether to allow major version upgrades.

      Default: false

      Parameters:
      allowMajorVersionUpgrade - Whether to allow major version upgrades. This parameter is required.
      Returns:
      this
    • databaseName

      @Stability(Stable) public DatabaseInstance.Builder databaseName(String databaseName)
      The name of the database.

      Default: - no name

      Parameters:
      databaseName - The name of the database. This parameter is required.
      Returns:
      this
    • instanceType

      @Stability(Stable) public DatabaseInstance.Builder instanceType(InstanceType instanceType)
      The name of the compute and memory capacity for the instance.

      Default: - m5.large (or, more specifically, db.m5.large)

      Parameters:
      instanceType - The name of the compute and memory capacity for the instance. This parameter is required.
      Returns:
      this
    • licenseModel

      @Stability(Stable) public DatabaseInstance.Builder licenseModel(LicenseModel licenseModel)
      The license model.

      Default: - RDS default license model

      Parameters:
      licenseModel - The license model. This parameter is required.
      Returns:
      this
    • parameters

      @Stability(Stable) public DatabaseInstance.Builder parameters(Map<String,String> parameters)
      The parameters in the DBParameterGroup to create automatically.

      You can only specify parameterGroup or parameters but not both. You need to use a versioned engine to auto-generate a DBParameterGroup.

      Default: - None

      Parameters:
      parameters - The parameters in the DBParameterGroup to create automatically. This parameter is required.
      Returns:
      this
    • timezone

      @Stability(Stable) public DatabaseInstance.Builder timezone(String timezone)
      The time zone of the instance.

      This is currently supported only by Microsoft Sql Server.

      Default: - RDS default timezone

      Parameters:
      timezone - The time zone of the instance. This parameter is required.
      Returns:
      this
    • characterSetName

      @Stability(Stable) public DatabaseInstance.Builder characterSetName(String characterSetName)
      For supported engines, specifies the character set to associate with the DB instance.

      Default: - RDS default character set name

      Parameters:
      characterSetName - For supported engines, specifies the character set to associate with the DB instance. This parameter is required.
      Returns:
      this
    • credentials

      @Stability(Stable) public DatabaseInstance.Builder credentials(Credentials credentials)
      Credentials for the administrative user.

      Default: - A username of 'admin' (or 'postgres' for PostgreSQL) and SecretsManager-generated password

      Parameters:
      credentials - Credentials for the administrative user. This parameter is required.
      Returns:
      this
    • storageEncrypted

      @Stability(Stable) public DatabaseInstance.Builder storageEncrypted(Boolean storageEncrypted)
      Indicates whether the DB instance is encrypted.

      Default: - true if storageEncryptionKey has been provided, false otherwise

      Parameters:
      storageEncrypted - Indicates whether the DB instance is encrypted. This parameter is required.
      Returns:
      this
    • storageEncryptionKey

      @Stability(Stable) public DatabaseInstance.Builder storageEncryptionKey(IKey storageEncryptionKey)
      The KMS key that's used to encrypt the DB instance.

      Default: - default master key if storageEncrypted is true, no key otherwise

      Parameters:
      storageEncryptionKey - The KMS key that's used to encrypt the DB instance. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public DatabaseInstance build()
      Specified by:
      build in interface software.amazon.jsii.Builder<DatabaseInstance>
      Returns:
      a newly built instance of DatabaseInstance.