Home

Awesome

<!-- markdownlint-disable -->

<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse/terraform-aws-rds-cluster/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/> <p align="right"> <a href="https://github.com/cloudposse/terraform-aws-rds-cluster/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/terraform-aws-rds-cluster.svg?style=for-the-badge" alt="Latest Release"/></a><a href="https://github.com/cloudposse/terraform-aws-rds-cluster/commits"><img src="https://img.shields.io/github/last-commit/cloudposse/terraform-aws-rds-cluster.svg?style=for-the-badge" alt="Last Updated"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"/></a></p>

<!-- markdownlint-restore --> <!-- ** DO NOT EDIT THIS FILE ** ** This file was automatically generated by the `cloudposse/build-harness`. ** 1) Make all changes to `README.yaml` ** 2) Run `make init` (you only need to do this once) ** 3) Run`make readme` to rebuild this file. ** ** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.) ** -->

Terraform module to provision an RDS Aurora cluster for MySQL or Postgres.

Supports Amazon Aurora Serverless.

[!TIP]

πŸ‘½ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform. <br/> Works with Github Actions, Atlantis, or Spacelift.

<details> <summary><strong>Watch demo of using Atmos with Terraform</strong></summary> <img src="https://github.com/cloudposse/atmos/blob/master/docs/demo.gif?raw=true"/><br/> <i>Example of running <a href="https://atmos.tools"><code>atmos</code></a> to manage infrastructure from our <a href="https://atmos.tools/quick-start/">Quick Start</a> tutorial.</i> </detalis>

Usage

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.

Basic example

module "rds_cluster_aurora_postgres" {
  source = "cloudposse/rds-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version     = "x.x.x"

  name            = "postgres"
  engine          = "aurora-postgresql"
  cluster_family  = "aurora-postgresql9.6"
  # 1 writer, 1 reader
  cluster_size    = 2
  # 1 writer, 3 reader
  # cluster_size    = 4
  # 1 writer, 5 reader
  # cluster_size    = 6
  namespace       = "eg"
  stage           = "dev"
  admin_user      = "admin1"
  admin_password  = "Test123456789"
  db_name         = "dbname"
  db_port         = 5432
  instance_type   = "db.r4.large"
  vpc_id          = "vpc-xxxxxxxx"
  security_groups = ["sg-xxxxxxxx"]
  subnets         = ["subnet-xxxxxxxx", "subnet-xxxxxxxx"]
  zone_id         = "Zxxxxxxxx"
}

Serverless Aurora MySQL 5.6

module "rds_cluster_aurora_mysql_serverless" {
  source = "cloudposse/rds-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version     = "x.x.x"
  namespace            = "eg"
  stage                = "dev"
  name                 = "db"
  engine               = "aurora"
  engine_mode          = "serverless"
  cluster_family       = "aurora5.6"
  cluster_size         = 0
  admin_user           = "admin1"
  admin_password       = "Test123456789"
  db_name              = "dbname"
  db_port              = 3306
  instance_type        = "db.t2.small"
  vpc_id               = "vpc-xxxxxxxx"
  security_groups      = ["sg-xxxxxxxx"]
  subnets              = ["subnet-xxxxxxxx", "subnet-xxxxxxxx"]
  zone_id              = "Zxxxxxxxx"
  enable_http_endpoint = true

  scaling_configuration = [
    {
      auto_pause               = true
      max_capacity             = 256
      min_capacity             = 2
      seconds_until_auto_pause = 300
    }
  ]
}

Serverless Aurora 2.07.1 MySQL 5.7

module "rds_cluster_aurora_mysql_serverless" {
  source = "cloudposse/rds-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version     = "x.x.x"
  namespace            = "eg"
  stage                = "dev"
  name                 = "db"
  engine               = "aurora-mysql"
  engine_mode          = "serverless"
  engine_version       = "5.7.mysql_aurora.2.07.1"
  cluster_family       = "aurora-mysql5.7"
  cluster_size         = 0
  admin_user           = "admin1"
  admin_password       = "Test123456789"
  db_name              = "dbname"
  db_port              = 3306
  vpc_id               = "vpc-xxxxxxxx"
  security_groups      = ["sg-xxxxxxxx"]
  subnets              = ["subnet-xxxxxxxx", "subnet-xxxxxxxx"]
  zone_id              = "Zxxxxxxxx"
  enable_http_endpoint = true

  scaling_configuration = [
    {
      auto_pause               = true
      max_capacity             = 16
      min_capacity             = 1
      seconds_until_auto_pause = 300
      timeout_action           = "ForceApplyCapacityChange"
    }
  ]
}

With cluster parameters

module "rds_cluster_aurora_mysql" {
  source = "cloudposse/rds-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version     = "x.x.x"
  engine          = "aurora"
  cluster_family  = "aurora-mysql5.7"
  cluster_size    = 2
  namespace       = "eg"
  stage           = "dev"
  name            = "db"
  admin_user      = "admin1"
  admin_password  = "Test123456789"
  db_name         = "dbname"
  instance_type   = "db.t2.small"
  vpc_id          = "vpc-xxxxxxx"
  security_groups = ["sg-xxxxxxxx"]
  subnets         = ["subnet-xxxxxxxx", "subnet-xxxxxxxx"]
  zone_id         = "Zxxxxxxxx"

  cluster_parameters = [
    {
      name  = "character_set_client"
      value = "utf8"
    },
    {
      name  = "character_set_connection"
      value = "utf8"
    },
    {
      name  = "character_set_database"
      value = "utf8"
    },
    {
      name  = "character_set_results"
      value = "utf8"
    },
    {
      name  = "character_set_server"
      value = "utf8"
    },
    {
      name  = "collation_connection"
      value = "utf8_bin"
    },
    {
      name  = "collation_server"
      value = "utf8_bin"
    },
    {
      name         = "lower_case_table_names"
      value        = "1"
      apply_method = "pending-reboot"
    },
    {
      name         = "skip-character-set-client-handshake"
      value        = "1"
      apply_method = "pending-reboot"
    }
  ]
}

With enhanced monitoring

# create IAM role for monitoring
resource "aws_iam_role" "enhanced_monitoring" {
  name               = "rds-cluster-example-1"
  assume_role_policy = data.aws_iam_policy_document.enhanced_monitoring.json
}

# Attach Amazon's managed policy for RDS enhanced monitoring
resource "aws_iam_role_policy_attachment" "enhanced_monitoring" {
  role       = aws_iam_role.enhanced_monitoring.name
  policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"
}

# allow rds to assume this role
data "aws_iam_policy_document" "enhanced_monitoring" {
  statement {
      actions = [
      "sts:AssumeRole",
    ]

    effect = "Allow"

    principals {
      type        = "Service"
      identifiers = ["monitoring.rds.amazonaws.com"]
    }
  }
}

module "rds_cluster_aurora_postgres" {
  source = "cloudposse/rds-cluster/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version     = "x.x.x"
  engine          = "aurora-postgresql"
  cluster_family  = "aurora-postgresql9.6"
  cluster_size    = 2
  namespace       = "eg"
  stage           = "dev"
  name            = "db"
  admin_user      = "admin1"
  admin_password  = "Test123456789"
  db_name         = "dbname"
  db_port         = 5432
  instance_type   = "db.r4.large"
  vpc_id          = "vpc-xxxxxxx"
  security_groups = ["sg-xxxxxxxx"]
  subnets         = ["subnet-xxxxxxxx", "subnet-xxxxxxxx"]
  zone_id         = "Zxxxxxxxx"

  # enable monitoring every 30 seconds
  rds_monitoring_interval = 30

  # reference iam role created above
  rds_monitoring_role_arn = aws_iam_role.enhanced_monitoring.arn
}

[!IMPORTANT] In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic approach for updating versions to avoid unexpected changes.

Examples

Review the complete example to see how to use this module.

<!-- markdownlint-disable -->

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code

<!-- markdownlint-restore --> <!-- markdownlint-disable -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.0.0
<a name="requirement_aws"></a> aws>= 4.23.0
<a name="requirement_null"></a> null>= 2.0
<a name="requirement_random"></a> random>= 2.0

Providers

NameVersion
<a name="provider_aws"></a> aws>= 4.23.0
<a name="provider_random"></a> random>= 2.0

Modules

NameSourceVersion
<a name="module_dns_master"></a> dns_mastercloudposse/route53-cluster-hostname/aws0.12.2
<a name="module_dns_replicas"></a> dns_replicascloudposse/route53-cluster-hostname/aws0.12.2
<a name="module_enhanced_monitoring_label"></a> enhanced_monitoring_labelcloudposse/label/null0.25.0
<a name="module_rds_identifier"></a> rds_identifiercloudposse/label/null0.25.0
<a name="module_this"></a> thiscloudposse/label/null0.25.0

Resources

NameType
aws_appautoscaling_policy.replicasresource
aws_appautoscaling_target.replicasresource
aws_db_parameter_group.defaultresource
aws_db_subnet_group.defaultresource
aws_iam_role.enhanced_monitoringresource
aws_iam_role_policy_attachment.enhanced_monitoringresource
aws_rds_cluster.primaryresource
aws_rds_cluster.secondaryresource
aws_rds_cluster_activity_stream.primaryresource
aws_rds_cluster_instance.defaultresource
aws_rds_cluster_parameter_group.defaultresource
aws_rds_reserved_instance.defaultresource
aws_security_group.defaultresource
aws_security_group_rule.egressresource
aws_security_group_rule.egress_ipv6resource
aws_security_group_rule.ingress_cidr_blocksresource
aws_security_group_rule.ingress_ipv6_cidr_blocksresource
aws_security_group_rule.ingress_security_groupsresource
aws_security_group_rule.traffic_inside_security_groupresource
random_pet.instanceresource
aws_iam_policy_document.enhanced_monitoringdata source
aws_partition.currentdata source
aws_rds_reserved_instance_offering.defaultdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_activity_stream_enabled"></a> activity_stream_enabledWhether to enable Activity Streamsboolfalseno
<a name="input_activity_stream_kms_key_id"></a> activity_stream_kms_key_idThe ARN for the KMS key to encrypt Activity Stream Data data. When specifying activity_stream_kms_key_id, activity_stream_enabled needs to be set to truestring""no
<a name="input_activity_stream_mode"></a> activity_stream_modeThe mode for the Activity Streams. async and sync are supported. Defaults to asyncstring"async"no
<a name="input_additional_tag_map"></a> additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration.map(string){}no
<a name="input_admin_password"></a> admin_passwordPassword for the master DB user. Ignored if snapshot_identifier or replication_source_identifier is providedstring""no
<a name="input_admin_user"></a> admin_userUsername for the master DB user. Ignored if snapshot_identifier or replication_source_identifier is providedstring"admin"no
<a name="input_admin_user_secret_kms_key_id"></a> admin_user_secret_kms_key_idAmazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key.<br/>To use a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN.<br/>If not specified, the default KMS key for your Amazon Web Services account is used.stringnullno
<a name="input_allocated_storage"></a> allocated_storageThe allocated storage in GBsnumbernullno
<a name="input_allow_major_version_upgrade"></a> allow_major_version_upgradeEnable to allow major engine version upgrades when changing engine versions. Defaults to false.boolfalseno
<a name="input_allowed_cidr_blocks"></a> allowed_cidr_blocksList of CIDR blocks allowed to access the clusterlist(string)[]no
<a name="input_allowed_ipv6_cidr_blocks"></a> allowed_ipv6_cidr_blocksList of IPv6 CIDR blocks allowed to access the clusterlist(string)[]no
<a name="input_apply_immediately"></a> apply_immediatelySpecifies whether any cluster modifications are applied immediately, or during the next maintenance windowbooltrueno
<a name="input_attributes"></a> attributesID element. Additional attributes (e.g. workers or cluster) to add to id,<br/>in the order they appear in the list. New attributes are appended to the<br/>end of the list. The elements of the list are joined by the delimiter<br/>and treated as a single ID element.list(string)[]no
<a name="input_auto_minor_version_upgrade"></a> auto_minor_version_upgradeIndicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance windowbooltrueno
<a name="input_autoscaling_enabled"></a> autoscaling_enabledWhether to enable cluster autoscalingboolfalseno
<a name="input_autoscaling_max_capacity"></a> autoscaling_max_capacityMaximum number of instances to be maintained by the autoscalernumber5no
<a name="input_autoscaling_min_capacity"></a> autoscaling_min_capacityMinimum number of instances to be maintained by the autoscalernumber1no
<a name="input_autoscaling_policy_type"></a> autoscaling_policy_typeAutoscaling policy type. TargetTrackingScaling and StepScaling are supportedstring"TargetTrackingScaling"no
<a name="input_autoscaling_scale_in_cooldown"></a> autoscaling_scale_in_cooldownThe amount of time, in seconds, after a scaling activity completes and before the next scaling down activity can start. Default is 300snumber300no
<a name="input_autoscaling_scale_out_cooldown"></a> autoscaling_scale_out_cooldownThe amount of time, in seconds, after a scaling activity completes and before the next scaling up activity can start. Default is 300snumber300no
<a name="input_autoscaling_target_metrics"></a> autoscaling_target_metricsThe metrics type to use. If this value isn't provided the default is CPU utilizationstring"RDSReaderAverageCPUUtilization"no
<a name="input_autoscaling_target_value"></a> autoscaling_target_valueThe target value to scale with respect to target metricsnumber75no
<a name="input_backtrack_window"></a> backtrack_windowThe target backtrack window, in seconds. Only available for aurora engine currently. Must be between 0 and 259200 (72 hours)number0no
<a name="input_backup_window"></a> backup_windowDaily time range during which the backups happenstring"07:00-09:00"no
<a name="input_ca_cert_identifier"></a> ca_cert_identifierThe identifier of the CA certificate for the DB instancestringnullno
<a name="input_cluster_dns_name"></a> cluster_dns_nameName of the cluster CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format master.var.namestring""no
<a name="input_cluster_family"></a> cluster_familyThe family of the DB cluster parameter groupstring"aurora5.6"no
<a name="input_cluster_identifier"></a> cluster_identifierThe RDS Cluster Identifier. Will use generated label ID if not suppliedstring""no
<a name="input_cluster_parameters"></a> cluster_parametersList of DB cluster parameters to apply<pre>list(object({<br/> apply_method = string<br/> name = string<br/> value = string<br/> }))</pre>[]no
<a name="input_cluster_size"></a> cluster_sizeNumber of DB instances to create in the clusternumber2no
<a name="input_cluster_type"></a> cluster_typeEither regional or global.<br/>If regional will be created as a normal, standalone DB.<br/>If global, will be made part of a Global cluster (requires global_cluster_identifier).string"regional"no
<a name="input_context"></a> contextSingle object for setting entire context at once.<br/>See description of individual variables for details.<br/>Leave string and numeric variables as null to use default value.<br/>Individual variable settings (non-null) override settings in context object,<br/>except for attributes, tags, and additional_tag_map, which are merged.any<pre>{<br/> "additional_tag_map": {},<br/> "attributes": [],<br/> "delimiter": null,<br/> "descriptor_formats": {},<br/> "enabled": true,<br/> "environment": null,<br/> "id_length_limit": null,<br/> "label_key_case": null,<br/> "label_order": [],<br/> "label_value_case": null,<br/> "labels_as_tags": [<br/> "unset"<br/> ],<br/> "name": null,<br/> "namespace": null,<br/> "regex_replace_chars": null,<br/> "stage": null,<br/> "tags": {},<br/> "tenant": null<br/>}</pre>no
<a name="input_copy_tags_to_snapshot"></a> copy_tags_to_snapshotCopy tags to backup snapshotsboolfalseno
<a name="input_db_cluster_instance_class"></a> db_cluster_instance_classThis setting is required to create a provisioned Multi-AZ DB clusterstringnullno
<a name="input_db_name"></a> db_nameDatabase name (default is not to create a database)string""no
<a name="input_db_port"></a> db_portDatabase portnumber3306no
<a name="input_deletion_protection"></a> deletion_protectionIf the DB instance should have deletion protection enabledboolfalseno
<a name="input_delimiter"></a> delimiterDelimiter to be used between ID elements.<br/>Defaults to - (hyphen). Set to "" to use no delimiter at all.stringnullno
<a name="input_descriptor_formats"></a> descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.<br/>Map of maps. Keys are names of descriptors. Values are maps of the form<br/>{<br/> format = string<br/> labels = list(string)<br/>}<br/>(Type is any so the map values can later be enhanced to provide additional options.)<br/>format is a Terraform format string to be passed to the format() function.<br/>labels is a list of labels, in order, to pass to format() function.<br/>Label values will be normalized before being passed to format() so they will be<br/>identical to how they appear in id.<br/>Default is {} (descriptors output will be empty).any{}no
<a name="input_egress_enabled"></a> egress_enabledWhether or not to apply the egress security group rule to default security group, defaults to truebooltrueno
<a name="input_enable_global_write_forwarding"></a> enable_global_write_forwardingSet to true, to forward writes to an associated global cluster.boolfalseno
<a name="input_enable_http_endpoint"></a> enable_http_endpointEnable HTTP endpoint (data API). Only valid when engine_mode is set to serverlessboolfalseno
<a name="input_enabled"></a> enabledSet to false to prevent the module from creating any resourcesboolnullno
<a name="input_enabled_cloudwatch_logs_exports"></a> enabled_cloudwatch_logs_exportsList of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquerylist(string)[]no
<a name="input_engine"></a> engineThe name of the database engine to be used for this DB cluster. Valid values: aurora, aurora-mysql, aurora-postgresqlstring"aurora"no
<a name="input_engine_mode"></a> engine_modeThe database engine mode. Valid values: parallelquery, provisioned, serverlessstring"provisioned"no
<a name="input_engine_version"></a> engine_versionThe version of the database engine to use. See aws rds describe-db-engine-versionsstring""no
<a name="input_enhanced_monitoring_attributes"></a> enhanced_monitoring_attributesThe attributes for the enhanced monitoring IAM rolelist(string)<pre>[<br/> "enhanced-monitoring"<br/>]</pre>no
<a name="input_enhanced_monitoring_role_enabled"></a> enhanced_monitoring_role_enabledA boolean flag to enable/disable the creation of the enhanced monitoring IAM role. If set to false, the module will not create a new role and will use rds_monitoring_role_arn for enhanced monitoringboolfalseno
<a name="input_environment"></a> environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
<a name="input_global_cluster_identifier"></a> global_cluster_identifierID of the Aurora global clusterstring""no
<a name="input_iam_database_authentication_enabled"></a> iam_database_authentication_enabledSpecifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabledboolfalseno
<a name="input_iam_roles"></a> iam_rolesIam roles for the Aurora clusterlist(string)[]no
<a name="input_id_length_limit"></a> id_length_limitLimit id to this many characters (minimum 6).<br/>Set to 0 for unlimited length.<br/>Set to null for keep the existing setting, which defaults to 0.<br/>Does not affect id_full.numbernullno
<a name="input_instance_availability_zone"></a> instance_availability_zoneOptional parameter to place cluster instances in a specific availability zone. If left empty, will place randomlystring""no
<a name="input_instance_parameters"></a> instance_parametersList of DB instance parameters to apply<pre>list(object({<br/> apply_method = string<br/> name = string<br/> value = string<br/> }))</pre>[]no
<a name="input_instance_type"></a> instance_typeInstance type to usestring"db.t2.small"no
<a name="input_intra_security_group_traffic_enabled"></a> intra_security_group_traffic_enabledWhether to allow traffic between resources inside the database's security group.boolfalseno
<a name="input_iops"></a> iopsThe amount of provisioned IOPS. Setting this implies a storage_type of 'io1'. This setting is required to create a Multi-AZ DB cluster. Check TF docs for values based on db enginenumbernullno
<a name="input_kms_key_arn"></a> kms_key_arnThe ARN for the KMS encryption key. When specifying kms_key_arn, storage_encrypted needs to be set to truestring""no
<a name="input_label_key_case"></a> label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.<br/>Does not affect keys of tags passed in via the tags input.<br/>Possible values: lower, title, upper.<br/>Default value: title.stringnullno
<a name="input_label_order"></a> label_orderThe order in which the labels (ID elements) appear in the id.<br/>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br/>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.list(string)nullno
<a name="input_label_value_case"></a> label_value_caseControls the letter case of ID elements (labels) as included in id,<br/>set as tag values, and output by this module individually.<br/>Does not affect values of tags passed in via the tags input.<br/>Possible values: lower, title, upper and none (no transformation).<br/>Set this to title and set delimiter to "" to yield Pascal Case IDs.<br/>Default value: lower.stringnullno
<a name="input_labels_as_tags"></a> labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.<br/>Default is to include all labels.<br/>Tags with empty values will not be included in the tags output.<br/>Set to [] to suppress all generated tags.<br/>Notes:<br/> The value of the name tag, if included, will be the id, not the name.<br/> Unlike other null-label inputs, the initial setting of labels_as_tags cannot be<br/> changed in later chained modules. Attempts to change it will be silently ignored.set(string)<pre>[<br/> "default"<br/>]</pre>no
<a name="input_maintenance_window"></a> maintenance_windowWeekly time range during which system maintenance can occur, in UTCstring"wed:03:00-wed:04:00"no
<a name="input_manage_admin_user_password"></a> manage_admin_user_passwordSet to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if master_password is providedboolfalseno
<a name="input_name"></a> nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br/>This is the only ID element not also included as a tag.<br/>The "name" tag is set to the full id string. There is no tag with the value of the name input.stringnullno
<a name="input_namespace"></a> namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
<a name="input_network_type"></a> network_typeThe network type of the cluster. Valid values: IPV4, DUAL.string"IPV4"no
<a name="input_parameter_group_name_prefix_enabled"></a> parameter_group_name_prefix_enabledSet to true to use name_prefix to name the cluster and database parameter groups. Set to false to use name insteadbooltrueno
<a name="input_performance_insights_enabled"></a> performance_insights_enabledWhether to enable Performance Insightsboolfalseno
<a name="input_performance_insights_kms_key_id"></a> performance_insights_kms_key_idThe ARN for the KMS key to encrypt Performance Insights data. When specifying performance_insights_kms_key_id, performance_insights_enabled needs to be set to truestring""no
<a name="input_performance_insights_retention_period"></a> performance_insights_retention_periodAmount of time in days to retain Performance Insights data. Either 7 (7 days) or 731 (2 years)numbernullno
<a name="input_publicly_accessible"></a> publicly_accessibleSet to true if you want your cluster to be publicly accessible (such as via QuickSight)boolfalseno
<a name="input_rds_monitoring_interval"></a> rds_monitoring_intervalThe 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, 60number0no
<a name="input_rds_monitoring_role_arn"></a> rds_monitoring_role_arnThe ARN for the IAM role that permits RDS to send enhanced monitoring metrics to CloudWatch Logsstringnullno
<a name="input_rds_ri_duration"></a> rds_ri_durationThe number of years to reserve the instance. Values can be 1 or 3 (or in seconds, 31536000 or 94608000)number1no
<a name="input_rds_ri_offering_type"></a> rds_ri_offering_typeOffering type of reserved DB instances. Valid values are 'No Upfront', 'Partial Upfront', 'All Upfront'.string""no
<a name="input_reader_dns_name"></a> reader_dns_nameName of the reader endpoint CNAME record to create in the parent DNS zone specified by zone_id. If left empty, the name will be auto-asigned using the format replicas.var.namestring""no
<a name="input_regex_replace_chars"></a> regex_replace_charsTerraform regular expression (regex) string.<br/>Characters matching the regex will be removed from the ID elements.<br/>If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.stringnullno
<a name="input_replication_source_identifier"></a> replication_source_identifierARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replicastring""no
<a name="input_restore_to_point_in_time"></a> restore_to_point_in_timeList of point-in-time recovery options. Valid parameters are:<br/><br/>source_cluster_identifier<br/> Identifier of the source database cluster from which to restore.<br/>restore_type:<br/> Type of restore to be performed. Valid options are "full-copy" and "copy-on-write".<br/>use_latest_restorable_time:<br/> Set to true to restore the database cluster to the latest restorable backup time. Conflicts with restore_to_time.<br/>restore_to_time:<br/> Date and time in UTC format to restore the database cluster to. Conflicts with use_latest_restorable_time.<pre>list(object({<br/> source_cluster_identifier = string<br/> restore_type = optional(string, "copy-on-write")<br/> use_latest_restorable_time = optional(bool, true)<br/> restore_to_time = optional(string, null)<br/> }))</pre>[]no
<a name="input_retention_period"></a> retention_periodNumber of days to retain backups fornumber5no
<a name="input_s3_import"></a> s3_importRestore from a Percona Xtrabackup in S3. The bucket_name is required to be in the same region as the resource.<pre>object({<br/> bucket_name = string<br/> bucket_prefix = string<br/> ingestion_role = string<br/> source_engine = string<br/> source_engine_version = string<br/> })</pre>nullno
<a name="input_scaling_configuration"></a> scaling_configurationList of nested attributes with scaling properties. Only valid when engine_mode is set to serverless<pre>list(object({<br/> auto_pause = bool<br/> max_capacity = number<br/> min_capacity = number<br/> seconds_until_auto_pause = number<br/> timeout_action = string<br/> }))</pre>[]no
<a name="input_security_groups"></a> security_groupsList of security groups to be allowed to connect to the DB instancelist(string)[]no
<a name="input_serverlessv2_scaling_configuration"></a> serverlessv2_scaling_configurationserverlessv2 scaling properties<pre>object({<br/> min_capacity = number<br/> max_capacity = number<br/> })</pre>nullno
<a name="input_skip_final_snapshot"></a> skip_final_snapshotDetermines whether a final DB snapshot is created before the DB cluster is deletedbooltrueno
<a name="input_snapshot_identifier"></a> snapshot_identifierSpecifies whether or not to create this cluster from a snapshotstringnullno
<a name="input_source_region"></a> source_regionSource Region of primary cluster, needed when using encrypted storage and region replicasstring""no
<a name="input_stage"></a> stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
<a name="input_storage_encrypted"></a> storage_encryptedSpecifies whether the DB cluster is encrypted. The default is false for provisioned engine_mode and true for serverless engine_modeboolfalseno
<a name="input_storage_type"></a> storage_typeOne of 'standard' (magnetic), 'gp2' (general purpose SSD), 'io1' (provisioned IOPS SSD), 'aurora', or 'aurora-iopt1'stringnullno
<a name="input_subnet_group_name"></a> subnet_group_nameDatabase subnet group name. Will use generated label ID if not supplied.string""no
<a name="input_subnets"></a> subnetsList of VPC subnet IDslist(string)n/ayes
<a name="input_tags"></a> tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).<br/>Neither the tag keys nor the tag values will be modified by this module.map(string){}no
<a name="input_tenant"></a> tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
<a name="input_timeouts_configuration"></a> timeouts_configurationList of timeout values per action. Only valid actions are create, update and delete<pre>list(object({<br/> create = string<br/> update = string<br/> delete = string<br/> }))</pre>[]no
<a name="input_use_reserved_instances"></a> use_reserved_instancesWARNING: Observe your plans and applies carefully when using this feature.<br/>It has potential to be very expensive if not used correctly.<br/><br/>Whether to use reserved instances.boolfalseno
<a name="input_vpc_id"></a> vpc_idVPC ID to create the cluster in (e.g. vpc-a22222ee)stringn/ayes
<a name="input_vpc_security_group_ids"></a> vpc_security_group_idsAdditional security group IDs to apply to the cluster, in addition to the provisioned default security group with ingress traffic from existing CIDR blocks and existing security groupslist(string)[]no
<a name="input_zone_id"></a> zone_idRoute53 DNS Zone ID as list of string (0 or 1 items). If empty, no custom DNS name will be published.<br/>If the list contains a single Zone ID, a custom DNS name will be pulished in that zone.<br/>Can also be a plain string, but that use is DEPRECATED because of Terraform issues.any[]no

Outputs

NameDescription
<a name="output_activity_stream_arn"></a> activity_stream_arnActivity Stream ARN
<a name="output_activity_stream_name"></a> activity_stream_nameActivity Stream Name
<a name="output_arn"></a> arnAmazon Resource Name (ARN) of the cluster
<a name="output_cluster_identifier"></a> cluster_identifierCluster Identifier
<a name="output_cluster_resource_id"></a> cluster_resource_idThe region-unique, immutable identifie of the cluster
<a name="output_cluster_security_groups"></a> cluster_security_groupsDefault RDS cluster security groups
<a name="output_database_name"></a> database_nameDatabase name
<a name="output_dbi_resource_ids"></a> dbi_resource_idsList of the region-unique, immutable identifiers for the DB instances in the cluster
<a name="output_endpoint"></a> endpointThe DNS address of the RDS instance
<a name="output_master_host"></a> master_hostDB Master hostname
<a name="output_master_username"></a> master_usernameUsername for the master DB user
<a name="output_reader_endpoint"></a> reader_endpointA read-only endpoint for the Aurora cluster, automatically load-balanced across replicas
<a name="output_replicas_host"></a> replicas_hostReplicas hostname
<a name="output_reserved_instance"></a> reserved_instanceAll information about the reserved instance(s) if created.
<a name="output_security_group_arn"></a> security_group_arnSecurity Group ARN
<a name="output_security_group_id"></a> security_group_idSecurity Group ID
<a name="output_security_group_name"></a> security_group_nameSecurity Group name
<!-- markdownlint-restore -->

Related Projects

Check out these related projects.

[!TIP]

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

βœ… We build it together with your team.<br/> βœ… Your team owns everything.<br/> βœ… 100% Open Source and backed by fanatical support.<br/>

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-cluster&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

<details><summary>πŸ“š <strong>Learn More</strong></summary> <br/>

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-cluster&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

Day-2: Your Operational Mastery

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-cluster&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

</details>

✨ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

<a href="https://github.com/cloudposse/terraform-aws-rds-cluster/graphs/contributors"> <img src="https://contrib.rocks/image?repo=cloudposse/terraform-aws-rds-cluster&max=24" /> </a>

For πŸ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

🌎 Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

πŸ“° Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β€” and usually a 5-minute read.

πŸ“† Office Hours <a href="https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-cluster&utm_content=office_hours"><img src="https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png" align="right" /></a>

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you can’t find anywhere else. It's FREE for everyone!

License

<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="License"></a>

<details> <summary>Preamble to the Apache License, Version 2.0</summary> <br/> <br/>

Complete license is available in the LICENSE file.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
</details>

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright Β© 2017-2024 Cloud Posse, LLC

<a href="https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-cluster&utm_content=readme_footer_link"><img alt="README footer" src="https://cloudposse.com/readme/footer/img"/></a>

<img alt="Beacon" width="0" src="https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-rds-cluster?pixel&cs=github&cm=readme&an=terraform-aws-rds-cluster"/>