From 56106b98cdc2d5cf358104c23a1e2dcf11d83ad6 Mon Sep 17 00:00:00 2001 From: Nikola Midic Date: Mon, 30 May 2022 13:44:11 +0100 Subject: [PATCH] Ability to specify different instance type for replicas --- README.md | 5 +++-- main.tf | 2 +- variables.tf | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1fc0a07..1da192f 100644 --- a/README.md +++ b/README.md @@ -180,8 +180,9 @@ resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres96_parameter_ | envname | Environment name (eg,test, stage or prod) | string | - | yes | | envtype | Environment type (eg,prod or nonprod) | string | - | yes | | final_snapshot_identifier | The 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_prefix | Prefix for cluster and instance identifier | string | `` | no | +| identifier_prefix | Prefix for cluster and instance identifier | string | `""` | no | | instance_type | Instance type to use | string | `db.t2.small` | no | +| replica_instance_type | Instance type to use for replicas | string | `"" (inherits instance_type)` | no | | monitoring_interval | The interval (seconds) between points when Enhanced Monitoring metrics are collected | string | `0` | no | | name | Name given to DB subnet group | string | - | yes | | password | Master DB password | string | - | yes | @@ -199,7 +200,7 @@ resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres96_parameter_ | replica_scale_out_cooldown | Cooldown in seconds before allowing further scaling operations after a scale out | string | `300` | no | | security_groups | VPC Security Group IDs | list | - | yes | | skip_final_snapshot | Should a final snapshot be created on cluster destroy | string | `false` | no | -| snapshot_identifier | DB snapshot to create this database from | string | `` | no | +| snapshot_identifier | DB snapshot to create this database from | string | `""` | no | | storage_encrypted | Specifies whether the underlying storage layer should be encrypted | string | `true` | no | | subnets | List of subnet IDs to use | list | - | yes | | username | Master DB username | string | `root` | no | diff --git a/main.tf b/main.tf index 2dc3638..fb5284e 100644 --- a/main.tf +++ b/main.tf @@ -204,7 +204,7 @@ resource "aws_rds_cluster_instance" "cluster_instance_n" { engine_version = var.engine-version identifier = var.identifier_prefix != "" ? format("%s-node-%d", var.identifier_prefix, count.index + 1) : format("%s-aurora-node-%d", var.envname, count.index + 1) cluster_identifier = aws_rds_cluster.default.id - instance_class = var.instance_type + instance_class = var.replica_instance_type != "" ? var.replica_instance_type : var.instance_type publicly_accessible = var.publicly_accessible db_subnet_group_name = aws_db_subnet_group.main.name db_parameter_group_name = var.db_parameter_group_name diff --git a/variables.tf b/variables.tf index 9d2f77f..ce0ecaf 100644 --- a/variables.tf +++ b/variables.tf @@ -46,6 +46,12 @@ variable "instance_type" { description = "Instance type to use" } +variable "replica_instance_type" { + type = string + default = "" + description = "Instance type to use for replicas. Inherits instance_type value if unspecified." +} + variable "publicly_accessible" { type = string default = "false"