Skip to content

Commit af8c0ec

Browse files
authored
feat: Support blue/green updates (#468)
Co-authored-by: magreenbaum <magreenbaum>
1 parent 2ef1963 commit af8c0ec

File tree

7 files changed

+30
-4
lines changed

7 files changed

+30
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ Users have the ability to:
245245
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | The Availability Zone of the RDS instance | `string` | `null` | no |
246246
| <a name="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period) | The days to retain backups for | `number` | `null` | no |
247247
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance\_window | `string` | `null` | no |
248+
| <a name="input_blue_green_update"></a> [blue\_green\_update](#input\_blue\_green\_update) | Enables low-downtime updates using RDS Blue/Green deployments. | `map(string)` | `{}` | no |
248249
| <a name="input_ca_cert_identifier"></a> [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | Specifies the identifier of the CA certificate for the DB instance | `string` | `null` | no |
249250
| <a name="input_character_set_name"></a> [character\_set\_name](#input\_character\_set\_name) | The character set name to use for DB encoding in Oracle instances. This can't be changed. See Oracle Character Sets Supported in Amazon RDS and Collations and Character Sets for Microsoft SQL Server for more information. This can only be set on creation | `string` | `null` | no |
250251
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data | `string` | `null` | no |

examples/complete-mysql/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ module "db" {
4949
backup_window = "03:00-06:00"
5050
enabled_cloudwatch_logs_exports = ["general"]
5151
create_cloudwatch_log_group = true
52+
blue_green_update = {
53+
enabled = true
54+
}
5255

53-
backup_retention_period = 0
54-
skip_final_snapshot = true
55-
deletion_protection = false
56+
skip_final_snapshot = true
57+
deletion_protection = false
5658

5759
performance_insights_enabled = true
5860
performance_insights_retention_period = 7

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module "db_instance" {
107107
auto_minor_version_upgrade = var.auto_minor_version_upgrade
108108
apply_immediately = var.apply_immediately
109109
maintenance_window = var.maintenance_window
110+
blue_green_update = var.blue_green_update
110111

111112
snapshot_identifier = var.snapshot_identifier
112113
copy_tags_to_snapshot = var.copy_tags_to_snapshot

modules/db_instance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ No modules.
4343
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | The Availability Zone of the RDS instance | `string` | `null` | no |
4444
| <a name="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period) | The days to retain backups for | `number` | `null` | no |
4545
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance\_window | `string` | `null` | no |
46+
| <a name="input_blue_green_update"></a> [blue\_green\_update](#input\_blue\_green\_update) | Enables low-downtime updates using RDS Blue/Green deployments. | `map(string)` | `{}` | no |
4647
| <a name="input_ca_cert_identifier"></a> [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | Specifies the identifier of the CA certificate for the DB instance | `string` | `null` | no |
4748
| <a name="input_character_set_name"></a> [character\_set\_name](#input\_character\_set\_name) | The character set name to use for DB encoding in Oracle instances. This can't be changed. See Oracle Character Sets Supported in Amazon RDS and Collations and Character Sets for Microsoft SQL Server for more information. This can only be set on creation. | `string` | `null` | no |
4849
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data | `string` | `null` | no |

modules/db_instance/main.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ resource "aws_db_instance" "this" {
7070
apply_immediately = var.apply_immediately
7171
maintenance_window = var.maintenance_window
7272

73+
# https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/blue-green-deployments.html
74+
dynamic "blue_green_update" {
75+
for_each = length(var.blue_green_update) > 0 ? [var.blue_green_update] : []
76+
77+
content {
78+
enabled = try(blue_green_update.value.enabled, null)
79+
}
80+
}
81+
7382
snapshot_identifier = var.snapshot_identifier
7483
copy_tags_to_snapshot = var.copy_tags_to_snapshot
7584
skip_final_snapshot = var.skip_final_snapshot
@@ -81,7 +90,7 @@ resource "aws_db_instance" "this" {
8190

8291
replicate_source_db = var.replicate_source_db
8392
replica_mode = var.replica_mode
84-
backup_retention_period = var.backup_retention_period
93+
backup_retention_period = length(var.blue_green_update) > 0 ? coalesce(var.backup_retention_period, 1) : var.backup_retention_period
8594
backup_window = var.backup_window
8695
max_allocated_storage = var.max_allocated_storage
8796
monitoring_interval = var.monitoring_interval

modules/db_instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ variable "maintenance_window" {
249249
default = null
250250
}
251251

252+
variable "blue_green_update" {
253+
description = "Enables low-downtime updates using RDS Blue/Green deployments."
254+
type = map(string)
255+
default = {}
256+
}
257+
252258
variable "backup_retention_period" {
253259
description = "The days to retain backups for"
254260
type = number

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ variable "maintenance_window" {
235235
default = null
236236
}
237237

238+
variable "blue_green_update" {
239+
description = "Enables low-downtime updates using RDS Blue/Green deployments."
240+
type = map(string)
241+
default = {}
242+
}
243+
238244
variable "backup_retention_period" {
239245
description = "The days to retain backups for"
240246
type = number

0 commit comments

Comments
 (0)