Note: This module is in alpha state and is likely to contain bugs and updates may introduce breaking changes. It is not recommended for production use at this time.
Terraform module for automating deployment of Amazon Aurora and related resources following AWS best practices.
- Aurora Provisioned cluster (MySQL & PostgreSQL)
- Aurora Global databases (MySQL & PostgreSQL)
To deploy the Terraform Amazon Aurora module, do the following:
-
Install Terraform. For instructions and a video tutorial, see Install Terraform.
-
Sign up and log into Terraform Cloud (There is a free tier available).
- Create a Terraform organization.
-
Configure Terraform Cloud API access. Run the following to generate a Terraform Cloud token from the command line interface:
terraform login --For Mac/Linux export TERRAFORM_CONFIG="$HOME/.terraform.d/credentials.tfrc.json" --For Windows export TERRAFORM_CONFIG="$HOME/AppData/Roaming/terraform.d/credentials.tfrc.json"
-
Install and configure the AWS Command Line Interface (AWS CLI).
-
If you don't have git installed, install git.
-
Clone this aws-ia/terraform-aws-rds-aurora repository using the following command:
git clone https://github.com/aws-ia/terraform-aws-rds-aurora.git
-
Change directory to the root repository directory.
cd terraform-aws-rds-aurora/
-
Set up a new terraform workspace.
cd setup_workspace terraform init terraform apply
-
Deploy Aurora Terraform module.
- To create VPC and deploy Aurora module
- Change to the deploy directory. Run
cd ../deploy
- Initialize the deploy directory. Run
terraform init
. - Start a Terraform run using the configuration files in your deploy directory. Run
terraform apply
orterraform apply -var-file="$HOME/.aws/terraform.tfvars"
(Note: The deployment is remotely run in Terraform Cloud)
- Change to the deploy directory. Run
- To deploy Aurora module into existing VPCs, pass the list of private subnets (var.Private_subnet_ids_p & var.Private_subnet_ids_s) directly to the Aurora module.
- To create VPC and deploy Aurora module
David Wright ([email protected]), Tony Vattahil ([email protected]), Arabinda Pani ([email protected]) and other contributors.
Name | Version |
---|---|
terraform | >= 1.3.0 |
aws | >= 5.30 |
random | >= 2.2 |
Name | Version |
---|---|
aws | >= 5.30 |
aws.primary | >= 5.30 |
aws.secondary | >= 5.30 |
random | >= 2.2 |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
password | Master DB password | string |
n/a | yes |
private_subnet_ids_p | A list of private subnet IDs in your Primary AWS region VPC | list(string) |
n/a | yes |
private_subnet_ids_s | A list of private subnet IDs in your Secondary AWS region VPC | list(string) |
n/a | yes |
region | The name of the primary AWS region you wish to deploy into | string |
n/a | yes |
sec_region | The name of the secondary AWS region you wish to deploy into | string |
n/a | yes |
allow_major_version_upgrade | Enable to allow major engine version upgrades when changing engine versions. Defaults to false |
bool |
true |
no |
auto_minor_version_upgrade | Determines whether minor engine upgrades will be performed automatically in the maintenance window | bool |
true |
no |
backup_retention_period | How long to keep backups for (in days) | number |
7 |
no |
database_name | Name for an automatically created database on cluster creation | string |
"mydb" |
no |
enable_audit_log | Enable MySQL audit log export to Amazon Cloudwatch. | bool |
false |
no |
enable_error_log | Enable MySQL error log export to Amazon Cloudwatch. | bool |
false |
no |
enable_general_log | Enable MySQL general log export to Amazon Cloudwatch. | bool |
false |
no |
enable_postgresql_log | Enable PostgreSQL log export to Amazon Cloudwatch. | bool |
false |
no |
enable_slowquery_log | Enable MySQL slowquery log export to Amazon Cloudwatch. | bool |
false |
no |
engine | Aurora database engine type: aurora (for MySQL 5.6-compatible Aurora), aurora-mysql (for MySQL 5.7-compatible Aurora), aurora-postgresql | string |
"aurora-postgresql" |
no |
engine_version_mysql | Aurora database engine version. | string |
"8.0.mysql_aurora.3.05.1" |
no |
engine_version_pg | Aurora database engine version. | string |
"15.4" |
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 |
identifier | Cluster identifier | string |
"aurora" |
no |
instance_class | Aurora DB Instance type. Specify db.serverless to create Aurora Serverless v2 instances. | string |
"db.r7g.large" |
no |
manage_master_user_password | Manage master user password using AWS Secrets Manager | bool |
false |
no |
monitoring_interval | Enhanced Monitoring interval in seconds | number |
1 |
no |
name | Prefix for resource names | string |
"aurora" |
no |
port | The port on which to accept connections | string |
"" |
no |
preferred_backup_window | When to perform DB backups | string |
"02:00-03:00" |
no |
primary_instance_count | instance count for primary Aurora cluster | number |
2 |
no |
secondary_instance_count | instance count for secondary Aurora cluster | number |
1 |
no |
serverless_v2_max_acu | Aurora Serverless v2 Maximum ACU | number |
16 |
no |
serverless_v2_min_acu | Aurora Serverless v2 Minimum ACU | number |
0.5 |
no |
setup_as_secondary | Setup aws_rds_cluster.primary Terraform resource as Secondary Aurora cluster after an unplanned Aurora Global DB failover | bool |
false |
no |
setup_globaldb | Setup Aurora Global Database with 1 Primary and 1 X-region Secondary cluster | bool |
false |
no |
skip_final_snapshot | skip creating a final snapshot before deleting the DB | bool |
true |
no |
snapshot_identifier | id of snapshot to restore. If you do not want to restore a db, leave the default empty string. | string |
"" |
no |
storage_encrypted | Specifies whether the underlying Aurora storage layer should be encrypted | bool |
false |
no |
storage_type | Specifies Aurora storage type: Aurora Standard vs. Aurora I/O-Optimized | string |
"" |
no |
tags | A map of tags to add to all resources. | map(string) |
{ |
no |
username | Master DB username | string |
"root" |
no |
Name | Description |
---|---|
aurora_cluster_database_name | Name for an automatically created database on Aurora cluster creation |
aurora_cluster_master_password | Aurora master User password |
aurora_cluster_master_username | Aurora master username |
primary_aurora_cluster_arn | The ARN of the Primary Aurora cluster |
primary_aurora_cluster_endpoint | Primary Aurora cluster endpoint |
primary_aurora_cluster_hosted_zone_id | Route53 hosted zone id of the Primary Aurora cluster |
primary_aurora_cluster_id | The ID of the Primary Aurora cluster |
primary_aurora_cluster_instance_endpoints | A list of all Primary Aurora cluster instance endpoints |
primary_aurora_cluster_instance_ids | A list of all Primary Aurora cluster instance ids |
primary_aurora_cluster_port | Primary Aurora cluster endpoint port |
primary_aurora_cluster_reader_endpoint | Primary Aurora cluster reader endpoint |
primary_aurora_cluster_resource_id | The Cluster Resource ID of the Primary Aurora cluster |
secondary_aurora_cluster_arn | The ARN of the Secondary Aurora cluster |
secondary_aurora_cluster_endpoint | Secondary Aurora cluster endpoint |
secondary_aurora_cluster_hosted_zone_id | Route53 hosted zone id of the Secondary Aurora cluster |
secondary_aurora_cluster_id | The ID of the Secondary Aurora cluster |
secondary_aurora_cluster_instance_endpoints | A list of all Secondary Aurora cluster instance endpoints |
secondary_aurora_cluster_instance_ids | A list of all Secondary Aurora cluster instance ids |
secondary_aurora_cluster_port | Secondary Aurora cluster endpoint port |
secondary_aurora_cluster_reader_endpoint | Secondary Aurora cluster reader endpoint |
secondary_aurora_cluster_resource_id | The Cluster Resource ID of the Secondary Aurora cluster |