Resource: awsRdsClusterInstance
Provides an RDS Cluster Instance Resource. A Cluster Instance Resource defines attributes that are specific to a single instance in a RDS Cluster, specifically running Amazon Aurora.
Unlike other RDS resources that support replication, with Amazon Aurora you do not designate a primary and subsequent replicas. Instead, you simply add RDS Instances and Aurora manages the replication. You can use the count meta-parameter to make multiple instances and join them all to the same RDS Cluster, or you may specify different Cluster Instance resources with various instanceClass
sizes.
For more information on Amazon Aurora, see Aurora on Amazon RDS in the Amazon RDS User Guide.
\~> NOTE: Deletion Protection from the RDS service can only be enabled at the cluster level, not for individual cluster instances. You can still add the preventDestroy
lifecycle behavior to your Terraform resource configuration if you desire protection from accidental deletion.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsRdsClusterDefault = new aws.rdsCluster.RdsCluster(this, "default", {
availabilityZones: ["us-west-2a", "us-west-2b", "us-west-2c"],
clusterIdentifier: "aurora-cluster-demo",
databaseName: "mydb",
masterPassword: "barbut8chars",
masterUsername: "foo",
});
const awsRdsClusterInstanceClusterInstances =
new aws.rdsClusterInstance.RdsClusterInstance(this, "cluster_instances", {
clusterIdentifier: awsRdsClusterDefault.id,
engine: awsRdsClusterDefault.engine,
engineVersion: awsRdsClusterDefault.engineVersion,
identifier: "aurora-cluster-demo-${count.index}",
instanceClass: "db.r4.large",
});
/*In most cases loops should be handled in the programming language context and
not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
you need to keep this like it is.*/
awsRdsClusterInstanceClusterInstances.addOverride("count", 2);
Argument Reference
For more detailed documentation about each argument, refer to the AWS official documentation.
The following arguments are supported:
identifier
- (Optional, Forces new resource) The identifier for the RDS instance, if omitted, Terraform will assign a random, unique identifier.identifierPrefix
- (Optional, Forces new resource) Creates a unique identifier beginning with the specified prefix. Conflicts withidentifier
.clusterIdentifier
- (Required, Forces new resource) The identifier of theawsRdsCluster
in which to launch this instance.engine
- (Optional, Forces new resource) The name of the database engine to be used for the RDS instance. Defaults toaurora
. Valid Values:aurora
,auroraMysql
,auroraPostgresql
. For information on the difference between the available Aurora MySQL engines see Comparison between Aurora MySQL 1 and Aurora MySQL 2 in the Amazon RDS User Guide.engineVersion
- (Optional) The database engine version.instanceClass
- (Required) The instance class to use. For details on CPU and memory, see Scaling Aurora DB Instances. Aurora usesdb.*
instance classes/types. Please see AWS Documentation for currently available instance classes and complete details.publiclyAccessible
- (Optional) Bool to control if instance is publicly accessible. Defaultfalse
. See the documentation on Creating DB Instances for more details on controlling this property.dbSubnetGroupName
- (Required ifpubliclyAccessible =False
, Optional otherwise, Forces new resource) A DB subnet group to associate with this DB instance. NOTE: This must match thedbSubnetGroupName
of the attachedawsRdsCluster
.dbParameterGroupName
- (Optional) The name of the DB parameter group to associate with this instance.applyImmediately
- (Optional) Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default isfalse
.monitoringRoleArn
- (Optional) The ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch Logs. You can find more information on the AWS Documentation what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances.monitoringInterval
- (Optional) The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60.promotionTier
- (Optional) Default 0. Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoted to writer.availabilityZone
- (Optional, Computed, Forces new resource) The EC2 Availability Zone that the DB instance is created in. See docs about the details.preferredBackupWindow
- (Optional) The daily time range during which automated backups are created if automated backups are enabled. Eg: "04:00-09:00". NOTE: IfpreferredBackupWindow
is set at the cluster level, this argument must be omitted.preferredMaintenanceWindow
- (Optional) The window to perform maintenance in. Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00".autoMinorVersionUpgrade
- (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Defaulttrue
.performanceInsightsEnabled
- (Optional) Specifies whether Performance Insights is enabled or not.performanceInsightsKmsKeyId
- (Optional) ARN for the KMS key to encrypt Performance Insights data. When specifyingperformanceInsightsKmsKeyId
,performanceInsightsEnabled
needs to be set to true.performanceInsightsRetentionPeriod
- (Optional) Amount of time in days to retain Performance Insights data. Valid values are7
,731
(2 years) or a multiple of31
. When specifyingperformanceInsightsRetentionPeriod
,performanceInsightsEnabled
needs to be set to true. Defaults to '7'.copyTagsToSnapshot
– (Optional, boolean) Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. Defaultfalse
.caCertIdentifier
- (Optional) The identifier of the CA certificate for the DB instance.tags
- (Optional) A map of tags to assign to the instance. If configured with a providerdefaultTags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
arn
- Amazon Resource Name (ARN) of cluster instanceclusterIdentifier
- The RDS Cluster Identifieridentifier
- The Instance identifierid
- The Instance identifierwriter
– Boolean indicating if this instance is writable.false
indicates this instance is a read replica.availabilityZone
- The availability zone of the instanceendpoint
- The DNS address for this instance. May not be writableengine
- The database engineengineVersionActual
- The database engine versionport
- The database portstorageEncrypted
- Specifies whether the DB cluster is encrypted.kmsKeyId
- The ARN for the KMS encryption key if one is set to the cluster.networkType
- The network type of the DB instance.dbiResourceId
- The region-unique, immutable identifier for the DB instance.performanceInsightsEnabled
- Specifies whether Performance Insights is enabled or not.performanceInsightsKmsKeyId
- The ARN for the KMS encryption key used by Performance Insights.tagsAll
- A map of tags assigned to the resource, including those inherited from the providerdefaultTags
configuration block.
Timeouts
create
- (Default90M
)update
- (Default90M
)delete
- (Default90M
)
Import
RDS Cluster Instances can be imported using the identifier
, e.g.,