From 79b0fee33cb13fbf1b29c73fc016589f52f50700 Mon Sep 17 00:00:00 2001 From: gappan <4885290+gappan@users.noreply.github.com> Date: Wed, 26 Jan 2022 10:12:42 +0100 Subject: [PATCH 1/2] Adding cluster param variable for major version upgrade --- README.md | 1 + main.tf | 43 ++++++++++++++++++++++--------------------- variables.tf | 5 +++++ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e825d95..fba7952 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ No modules. | [data\_reader\_route53\_zone\_id](#input\_data\_reader\_route53\_zone\_id) | If specified a data reader route53 record will be created | `string` | `""` | no | | [data\_reader\_tags](#input\_data\_reader\_tags) | A map of tags to add to data reader resources. | `map(string)` | `{}` | no | | [db\_cluster\_parameter\_group\_name](#input\_db\_cluster\_parameter\_group\_name) | The name of a DB Cluster parameter group to use | `string` | `"default.aurora5.6"` | no | +| [db\_instance\_parameter\_group\_name](#input\_db\_instance\_parameter\_group\_name) | Instance parameter group to associate with all instances of the DB cluster. The db\_instance\_parameter\_group\_name parameter is only valid in combination with the allow\_major\_version\_upgrade parameter. | `any` | `null` | no | | [db\_parameter\_group\_name](#input\_db\_parameter\_group\_name) | The name of a DB parameter group to use | `string` | `"default.aurora5.6"` | no | | [delete\_timeout](#input\_delete\_timeout) | Timeout used for destroying cluster. This includes any cleanup task during the destroying process. | `string` | `"120m"` | no | | [deletion\_protection](#input\_deletion\_protection) | The database can't be deleted when this value is set to true. | `bool` | `true` | no | diff --git a/main.tf b/main.tf index 95d90e0..ddc567a 100644 --- a/main.tf +++ b/main.tf @@ -26,27 +26,28 @@ resource "aws_db_subnet_group" "main" { resource "aws_rds_cluster" "main" { count = var.create_resources ? 1 : 0 - allow_major_version_upgrade = var.allow_major_version_upgrade - cluster_identifier = "${var.identifier_prefix}${var.name}" - engine = var.engine - engine_version = var.engine_version - kms_key_id = var.kms_key_id - master_username = var.username - master_password = local.master_password - deletion_protection = var.deletion_protection - final_snapshot_identifier = "${var.final_snapshot_identifier_prefix}${var.name}-${random_id.snapshot_identifier[0].hex}" - skip_final_snapshot = var.skip_final_snapshot - backup_retention_period = var.backup_retention_period - preferred_backup_window = var.preferred_backup_window - preferred_maintenance_window = var.preferred_maintenance_window - port = local.port - db_subnet_group_name = aws_db_subnet_group.main[0].name - vpc_security_group_ids = concat([aws_security_group.main[0].id], var.extra_security_groups) - snapshot_identifier = var.snapshot_identifier - storage_encrypted = var.storage_encrypted - apply_immediately = var.apply_immediately - db_cluster_parameter_group_name = var.db_cluster_parameter_group_name - tags = var.tags + allow_major_version_upgrade = var.allow_major_version_upgrade + cluster_identifier = "${var.identifier_prefix}${var.name}" + engine = var.engine + engine_version = var.engine_version + kms_key_id = var.kms_key_id + master_username = var.username + master_password = local.master_password + deletion_protection = var.deletion_protection + final_snapshot_identifier = "${var.final_snapshot_identifier_prefix}${var.name}-${random_id.snapshot_identifier[0].hex}" + skip_final_snapshot = var.skip_final_snapshot + backup_retention_period = var.backup_retention_period + preferred_backup_window = var.preferred_backup_window + preferred_maintenance_window = var.preferred_maintenance_window + port = local.port + db_instance_parameter_group_name = var.allow_major_version_upgrade ? var.db_cluster_db_instance_parameter_group_name : null + db_subnet_group_name = aws_db_subnet_group.main[0].name + vpc_security_group_ids = concat([aws_security_group.main[0].id], var.extra_security_groups) + snapshot_identifier = var.snapshot_identifier + storage_encrypted = var.storage_encrypted + apply_immediately = var.apply_immediately + db_cluster_parameter_group_name = var.db_cluster_parameter_group_name + tags = var.tags timeouts { create = var.create_timeout diff --git a/variables.tf b/variables.tf index ebaeaeb..3fc1e37 100644 --- a/variables.tf +++ b/variables.tf @@ -39,6 +39,11 @@ variable "allow_major_version_upgrade" { default = false } +variable "db_instance_parameter_group_name" { + description = "Instance parameter group to associate with all instances of the DB cluster. The db_instance_parameter_group_name parameter is only valid in combination with the allow_major_version_upgrade parameter." + default = null +} + variable "allowed_security_groups" { description = "A list of Security Group ID's to allow access to." default = [] From 22f239497b5b0e142a720338110cc62c5a83a94a Mon Sep 17 00:00:00 2001 From: gappan <4885290+gappan@users.noreply.github.com> Date: Wed, 26 Jan 2022 12:07:32 +0100 Subject: [PATCH 2/2] Fixing the variable name --- README.md | 2 +- variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fba7952..c755eeb 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ No modules. | [data\_reader\_route53\_zone\_id](#input\_data\_reader\_route53\_zone\_id) | If specified a data reader route53 record will be created | `string` | `""` | no | | [data\_reader\_tags](#input\_data\_reader\_tags) | A map of tags to add to data reader resources. | `map(string)` | `{}` | no | | [db\_cluster\_parameter\_group\_name](#input\_db\_cluster\_parameter\_group\_name) | The name of a DB Cluster parameter group to use | `string` | `"default.aurora5.6"` | no | -| [db\_instance\_parameter\_group\_name](#input\_db\_instance\_parameter\_group\_name) | Instance parameter group to associate with all instances of the DB cluster. The db\_instance\_parameter\_group\_name parameter is only valid in combination with the allow\_major\_version\_upgrade parameter. | `any` | `null` | no | +| [db\_cluster\_db\_instance\_parameter\_group\_name](#input\_db\_cluster\_db\_instance\_parameter\_group\_name) | Instance parameter group to associate with all instances of the DB cluster. The db\_instance\_parameter\_group\_name parameter is only valid in combination with the allow\_major\_version\_upgrade parameter. | `any` | `null` | no | | [db\_parameter\_group\_name](#input\_db\_parameter\_group\_name) | The name of a DB parameter group to use | `string` | `"default.aurora5.6"` | no | | [delete\_timeout](#input\_delete\_timeout) | Timeout used for destroying cluster. This includes any cleanup task during the destroying process. | `string` | `"120m"` | no | | [deletion\_protection](#input\_deletion\_protection) | The database can't be deleted when this value is set to true. | `bool` | `true` | no | diff --git a/variables.tf b/variables.tf index 3fc1e37..de39af8 100644 --- a/variables.tf +++ b/variables.tf @@ -39,7 +39,7 @@ variable "allow_major_version_upgrade" { default = false } -variable "db_instance_parameter_group_name" { +variable "db_cluster_db_instance_parameter_group_name" { description = "Instance parameter group to associate with all instances of the DB cluster. The db_instance_parameter_group_name parameter is only valid in combination with the allow_major_version_upgrade parameter." default = null }