Skip to content

AWS Aurora Terraform Module for Rackspace customers.

License

Notifications You must be signed in to change notification settings

rackspace-infrastructure-automation/aws-terraform-aurora

Repository files navigation

aws-terraform-aurora

This module creates an aurora RDS cluster. The module currently supports the aurora, aurora-mysql, and aurora-postgres engines.

The module will output the required configuration files to enable client and worker node setup and configuration.

Basic Usage

module "aurora_master" {
  source = "git@github.com:rackspace-infrastructure-automation/aws-terraform-aurora//?ref=v0.12.1"

  binlog_format = "MIXED"
  engine        = "aurora"

  instance_availability_zone_list = [
    "us-west-2a",
    "us-west-2b",
    "us-west-2c",
  ]

  instance_class    = "db.t2.medium"
  name              = "sample-aurora-master"
  password          = "${data.aws_kms_secrets.rds_credentials.plaintext["password"]}"
  replica_instances = 2
  security_groups   = ["${module.vpc.default_sg}"]
  storage_encrypted = true
  subnets           = "${module.vpc.private_subnets}"
}

Full working references are available at examples

Other TF Modules Used

Using aws-terraform-cloudwatch_alarm to create the following CloudWatch Alarms:

  • high_cpu
  • write_io_high
  • read_io_high

Requirements

Name Version
terraform >= 0.12
aws >= 2.7.0

Providers

Name Version
aws >= 2.7.0
null n/a

Modules

Name Source Version
high_cpu git@github.com:rackspace-infrastructure-automation/aws-terraform-cloudwatch_alarm//?ref=v0.12.6
read_io_high git@github.com:rackspace-infrastructure-automation/aws-terraform-cloudwatch_alarm//?ref=v0.12.6
write_io_high git@github.com:rackspace-infrastructure-automation/aws-terraform-cloudwatch_alarm//?ref=v0.12.6

Resources

Name
aws_caller_identity
aws_db_parameter_group
aws_db_subnet_group
aws_iam_policy_document
aws_iam_role
aws_iam_role_policy_attachment
aws_rds_cluster
aws_rds_cluster_instance
aws_rds_cluster_parameter_group
aws_region
aws_route53_record
null_data_source

Inputs

Name Description Type Default Required
alarm_cpu_limit CloudWatch CPUUtilization Threshold number 60 no
alarm_read_iops_limit CloudWatch Read IOPSLimit Threshold number 60 no
alarm_write_iops_limit CloudWatch Write IOPSLimit Threshold number 100000 no
auto_minor_version_upgrade Boolean value that indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window bool true no
backtrack_window The target backtrack window, in seconds. Defaults to 1 day. Setting only affects supported versions (currently MySQL 5.6). Disable by setting to '0'. number 86400 no
backup_retention_period The number of days for which automated backups are retained. The permissible range is a value between 1-35. The aurora service defaults to 1 day but this module defaults to 35. Rackspace best practice is 30+ days. number 35 no
backup_window The daily time range during which automated backups are created if automated backups are enabled. string "05:00-06:00" no
binlog_format Sets the desired format. Defaults to OFF. Should be set to MIXED if this Aurora cluster will replicate to another RDS Instance or cluster. Ignored for aurora-postgresql engine string "OFF" no
cloudwatch_exports_logs_list List of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: audit, error, general, slowquery. list(string) [] no
cluster_internal_record_name The full record name you would like to add as a CNAME for the cluster that matches your Hosted Zone. i.e. cluster.example.com string "" no
cluster_parameters List of custom cluster parameters to apply to the parameter group. list(map(string)) [] no
create_internal_zone_record Create an internal Route 53 record for the RDS cluster and cluster reader. Default is false. bool false no
db_snapshot_arn The identifier for the DB cluster snapshot from which you want to restore. string "" no
dbname The DB name to create. If omitted, no database is created initially string "" no
enable_delete_protection If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. The default is false bool false no
engine Database Engine Type. Allowed values: aurora-mysql, aurora, aurora-postgresql string "aurora-mysql" no
engine_mode The database engine mode. Allowed values: provisioned and global(aurora engine only). string "provisioned" no
engine_version Database Engine Minor Version http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html string "" no
environment Application environment for which this network is being created. one of: ('Development', 'Integration', 'PreProduction', 'Production', 'QA', 'Staging', 'Test') string "Development" no
existing_cluster_parameter_group_name The existing cluster parameter group to use for this instance. (OPTIONAL) string "" no
existing_monitoring_role ARN of an existing enhanced monitoring role to use for this instance. (OPTIONAL) string "" no
existing_parameter_group_name The existing parameter group to use for this instance. (OPTIONAL) string "" no
existing_subnet_group The existing DB subnet group to use for this cluster (OPTIONAL) string "" no
family Parameter Group Family Name (ex. aurora5.6, aurora-postgresql9.6, aurora-mysql5.7) string "" no
global_cluster_identifier Global Cluster identifier. Property of aws_rds_global_cluster (Ignored if engine_mode is not 'global'). string "" no
instance_availability_zone_list List of availability zones to place each aurora instance. Availability zone assignment is by index. The first AZ in the list is assigned to the first instance,
second AZ in the list to the second instance, third AZ in the list to the third instance, etc. Also please remember that the number of AZs specified here should equal to replica_instances + 1.
list(string)
[
""
]
no
instance_class The database instance type. string n/a yes
internal_zone_id The zone id you would like the internal records for the cluster and reader to be created in. i.e. Z2QHD5YD1WXE9M string "" no
kms_key_id KMS Key Arn to use for storage encryption. (OPTIONAL) string "" no
maintenance_window The weekly time range (in UTC) during which system maintenance can occur. string "Sun:07:00-Sun:08:00" no
monitoring_interval 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. number 0 no
name The name prefix to use for the resources created in this module. string n/a yes
notification_topic List of SNS Topic ARNs to use for customer notifications from CloudWatch alarms. (OPTIONAL) list(string) [] no
options List of custom options to apply to the option group. list(string) [] no
parameters List of custom parameters to apply to the parameter group. list(map(string)) [] no
password Password for the local administrator account. string n/a yes
performance_insights_enable Specifies whether Performance Insights is enabled or not. bool false no
performance_insights_kms_key_id (Optional) The 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 true. string "" no
port The port on which the DB accepts connections string "" no
publicly_accessible Boolean value that indicates whether the database instances are Internet-facing. bool false no
rackspace_alarms_enabled Specifies whether non-emergency rackspace alarms will create a ticket. bool false no
rackspace_managed Boolean parameter controlling if instance will be fully managed by Rackspace support teams, created CloudWatch alarms that generate tickets, and utilize Rackspace managed SSM documents. bool true no
reader_internal_record_name The full record name you would like to add as a CNAME for the cluster reader. i.e. reader.example.com string "" no
replica_instances The number of Aurora replica instances to create. This can range from 0 to 15. number 1 no
security_groups A list of EC2 security groups to assign to this resource list(string) n/a yes
skip_final_snapshot Boolean value to control if the DB Cluster will take a final snapshot when destroyed. This value should be set to false if a final snapshot is desired. bool false no
source_cluster The cluster ID of the master Aurora cluster that will replicate to the created cluster. The master must be in a different region. Leave this parameter blank to create a master Aurora cluster. string "" no
source_region The region of the master Aurora cluster that will replicate to the created cluster. The master must be in a different region. Leave this parameter blank to create a master Aurora cluster. string "" no
storage_encrypted Specifies whether the DB instance is encrypted bool false no
subnets Subnets for RDS Instances list(string) n/a yes
tags Custom tags to apply to all resources. map(string) {} no
username The name of master user for the client DB instance. string "dbadmin" no

Outputs

Name Description
cluster_endpoint_address The DNS address of the RDS cluster
cluster_endpoint_port The port of the RDS cluster
cluster_endpoint_reader A read-only endpoint for the Aurora cluster
cluster_id The DB Cluster identifier
db_instance The DB instance identifier
monitoring_role The IAM role used for Enhanced Monitoring
parameter_group The Parameter Group used by the DB Instance
subnet_group The DB Subnet Group used by the DB Instance