Terraform module which creates RDS Aurora database resources on AWS and can create different type of databases. Currently it supports Postgres and MySQL.
We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.
This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.
This module has a few dependencies:
- Terraform 0.13
- Go
- github.com/stretchr/testify/assert
- github.com/gruntwork-io/terratest/modules/terraform
IMPORTANT: Since the master
branch used in source
varies based on new modifications, we suggest that you use the release versions here.
Here are some examples of how you can use this module in your inventory structure:
module "aurora" {
source = "clouddrove/aurora/aws"
version = "0.13.0"
name = "backend"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]
username = "admin"
database_name = "dt"
engine = "aurora-mysql"
engine_version = "5.7.12"
subnets = "subnet-xxxxxxxxx"
aws_security_group = [sg-xxxxxxxxxxx]
replica_count = 1
instance_type = "db.t2.medium"
apply_immediately = true
skip_final_snapshot = true
publicly_accessible = false
}
module "postgres" {
source = "clouddrove/aurora/aws"
version = "0.13.0"
name = "backend"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]
username = "root"
database_name = "test_db"
engine = "aurora-postgresql"
engine_version = "9.6.9"
subnets = "subnet-xxxxxxxxx"
aws_security_group = [sg-xxxxxxxxxxx]
replica_count = 1
instance_type = "db.r4.large"
apply_immediately = true
skip_final_snapshot = true
publicly_accessible = false
}
module "aurora" {
source = "clouddrove/aurora/aws"
version = "0.13.0"
name = "aurora-mysql-serverless"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]
enable = true
serverless_enabled = true
min_capacity = 1
max_capacity = 4
username = "root"
database_name = "test_db"
engine = "aurora"
engine_version = "5.6.10a"
kms_key_id = module.kms_key.key_arn
subnets = "subnet-xxxxxxxxx"
aws_security_group = [sg-xxxxxxxxxxx]
apply_immediately = true
skip_final_snapshot = true
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
}
module "postgres" {
source = "clouddrove/aurora/aws"
version = "0.13.0"
name = "aurora-postgresql-serverless"
application = "clouddrove"
environment = "test"
label_order = ["environment", "application", "name"]
enable = true
serverless_enabled = true
min_capacity = 2
max_capacity = 4
username = "root"
database_name = "test_db"
engine = "aurora-postgresql"
engine_version = "10.7"
kms_key_id = module.kms_key.key_arn
subnets = "subnet-xxxxxxxxx"
aws_security_group = [sg-xxxxxxxxxxx]
apply_immediately = true
skip_final_snapshot = true
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
application | Application (e.g. cd or clouddrove ). |
string |
"" |
no |
apply_immediately | Determines whether or not any DB modifications are applied immediately, or during the maintenance window. | bool |
false |
no |
auto_minor_version_upgrade | Determines whether minor engine upgrades will be performed automatically in the maintenance window. | bool |
true |
no |
auto_pause | Whether to enable automatic pause. A DB cluster can be paused only when it's idle (it has no connections). | bool |
false |
no |
availability_zone | The Availability Zone of the RDS instance. | string |
"" |
no |
availability_zones | The Availability Zone of the RDS cluster. | list |
[] |
no |
aws_security_group | Specifies whether IAM Database authentication should be enabled or not. Not all versions and instances are supported. Refer to the AWS documentation to see which versions are supported. | list(string) |
[] |
no |
backtrack_window | The target backtrack window, in seconds. Only available for aurora engine currently.Must be between 0 and 259200 (72 hours) | number |
0 |
no |
backup_retention_period | How long to keep backups for (in days). | number |
7 |
no |
copy_tags_to_snapshot | On delete, copy all Instance tags to the final snapshot (if final_snapshot_identifier is specified). | bool |
false |
no |
database_name | Name for an automatically created database on cluster creation. | string |
"" |
no |
db_cluster_parameter_group_name | The name of a DB Cluster parameter group to use. | string |
"default.aurora5.6" |
no |
db_parameter_group_name | The name of a DB parameter group to use. | string |
"default.aurora5.6" |
no |
deletion_protection | If the DB instance should have deletion protection enabled. | bool |
false |
no |
enable | Set to false to prevent the module from creating any resources. | bool |
true |
no |
enable_http_endpoint | Enable HTTP endpoint (data API). Only valid when engine_mode is set to serverless. | bool |
true |
no |
enabled_cloudwatch_logs_exports | 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, postgresql (PostgreSQL). | list(string) |
[] |
no |
enabled_rds_cluster | Set to false to prevent the module from creating any resources. | bool |
true |
no |
enabled_subnet_group | Set to false to prevent the module from creating any resources. | bool |
true |
no |
engine | Aurora database engine type, currently aurora, aurora-mysql or aurora-postgresql. | string |
"aurora-mysql" |
no |
engine_mode | The database engine mode. | string |
"serverless" |
no |
engine_version | Aurora database engine version. | string |
"5.6.10a" |
no |
environment | Environment (e.g. prod , dev , staging ). |
string |
"" |
no |
final_snapshot_identifier_prefix | The prefix name to use when creating a final snapshot on cluster destroy, appends a random 8 digits to name to ensure it's unique too. | string |
"final" |
no |
iam_database_authentication_enabled | Specifies whether IAM Database authentication should be enabled or not. Not all versions and instances are supported. Refer to the AWS documentation to see which versions are supported. | bool |
false |
no |
iam_roles | A List of ARNs for the IAM roles to associate to the RDS Cluster. | list(string) |
[] |
no |
identifier_prefix | Prefix for cluster and instance identifier. | string |
"" |
no |
instance_type | Instance type to use. | string |
"" |
no |
kms_key_id | The ARN for the KMS encryption key if one is set to the cluster. | string |
"" |
no |
label_order | Label order, e.g. name ,application . |
list |
[] |
no |
managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string |
"anmol@clouddrove.com" |
no |
max_capacity | The maximum capacity. Valid capacity values are 1, 2, 4, 8, 16, 32, 64, 128, and 256. | number |
4 |
no |
min_capacity | The minimum capacity. Valid capacity values are 1, 2, 4, 8, 16, 32, 64, 128, and 256. | number |
2 |
no |
monitoring_interval | The interval (seconds) between points when Enhanced Monitoring metrics are collected. | number |
0 |
no |
mysql_family | The family of the DB parameter group. | string |
"aurora-mysql5.7" |
no |
mysql_family_serverless | The family of the DB parameter group. | string |
"aurora5.6" |
no |
name | Name (e.g. app or cluster ). |
string |
n/a | yes |
password | Master DB password. | string |
"" |
no |
performance_insights_enabled | Specifies whether Performance Insights is enabled or not. | bool |
false |
no |
performance_insights_kms_key_id | The ARN for the KMS key to encrypt Performance Insights data. | string |
"" |
no |
port | The port on which to accept connections. | string |
"" |
no |
postgresql_family | The family of the DB parameter group. | string |
"aurora-postgresql9.6" |
no |
postgresql_family_serverless | The family of the DB parameter group. | string |
"aurora-postgresql10" |
no |
preferred_backup_window | When to perform DB backups. | string |
"02:00-03:00" |
no |
preferred_maintenance_window | When to perform DB maintenance. | string |
"sun:05:00-sun:06:00" |
no |
publicly_accessible | Whether the DB should have a public IP address. | bool |
false |
no |
replica_count | Number of reader nodes to create. If replica_scale_enable is true , the value of replica_scale_min is used instead. |
number |
1 |
no |
replica_scale_cpu | CPU usage to trigger autoscaling. | number |
70 |
no |
replica_scale_enabled | Whether to enable autoscaling for RDS Aurora (MySQL) read replicas. | bool |
false |
no |
replica_scale_in_cooldown | Cooldown in seconds before allowing further scaling operations after a scale in. | number |
300 |
no |
replica_scale_max | Maximum number of replicas to allow scaling. | number |
0 |
no |
replica_scale_min | Minimum number of replicas to allow scaling. | number |
2 |
no |
replica_scale_out_cooldown | Cooldown in seconds before allowing further scaling operations after a scale out. | number |
300 |
no |
replication_source_identifier | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. | string |
"" |
no |
seconds_until_auto_pause | The time, in seconds, before an Aurora DB cluster in serverless mode is paused. Valid values are 300 through 86400. | number |
300 |
no |
serverless_enabled | Whether serverless is enabled or not. | bool |
false |
no |
skip_final_snapshot | Should a final snapshot be created on cluster destroy. | bool |
false |
no |
snapshot_identifier | DB snapshot to create this database from. | string |
"" |
no |
source_region | The source region for an encrypted replica DB cluster. | string |
"" |
no |
storage_encrypted | Specifies whether the underlying storage layer should be encrypted. | bool |
true |
no |
subnets | List of subnet IDs to use. | list(string) |
[] |
no |
timeout_action | The action to take when the timeout is reached. Valid values: ForceApplyCapacityChange, RollbackCapacityChange. | string |
"RollbackCapacityChange" |
no |
username | Master DB username. | string |
"" |
no |
Name | Description |
---|---|
rds_cluster_database_name | Name for an automatically created database on cluster creation. |
rds_cluster_endpoint | The cluster endpoint. |
rds_cluster_id | The ID of the cluster. |
rds_cluster_instance_endpoints | A list of all cluster instance endpoints. |
rds_cluster_master_password | The master password. |
rds_cluster_master_username | The master username. |
rds_cluster_port | The port of Cluster. |
rds_cluster_reader_endpoint | The cluster reader endpoint. |
serverless_rds_cluster_database_name | Name for an automatically created database on cluster creation. |
serverless_rds_cluster_endpoint | The cluster endpoint. |
serverless_rds_cluster_id | The ID of the cluster. |
serverless_rds_cluster_master_password | The master password. |
serverless_rds_cluster_master_username | The master username. |
serverless_rds_cluster_port | The port of Cluster. |
serverless_rds_cluster_reader_endpoint | The cluster reader endpoint. |
tags | A mapping of tags to assign to the resource. |
In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.
You need to run the following command in the testing folder:
go test -run Test
If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at hello@clouddrove.com.
If you have found it worth your time, go ahead and give us a ★ on our GitHub!
At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
We are The Cloud Experts!
We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.