From 81010334e61c79a497851568e63c746ea79d73ae Mon Sep 17 00:00:00 2001 From: Ryan Fisher Date: Fri, 8 Nov 2019 16:14:39 -0800 Subject: [PATCH] Allow the option group verison to be empty/optional --- README.md | 1 + main.tf | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1928f46..bbfa5af 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ Available targets: | name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | - | yes | | namespace | Namespace (e.g. `eg` or `cp`) | string | `` | no | | option_group_name | Name of the DB option group to associate | string | `` | no | +| option_group_version | A version identifier to append to the option group name | string | `` | no | | parameter_group_name | Name of the DB parameter group to associate | string | `` | no | | publicly_accessible | Determines if database can be publicly available (NOT recommended) | bool | `false` | no | | security_group_ids | The IDs of the security groups from which to allow `ingress` traffic to the DB instance | list(string) | `` | no | diff --git a/main.tf b/main.tf index 35e00d5..27b4560 100644 --- a/main.tf +++ b/main.tf @@ -83,11 +83,15 @@ resource "aws_db_parameter_group" "default" { value = parameter.value.value } } + + lifecycle { + create_before_destroy = true + } } resource "aws_db_option_group" "default" { count = length(var.option_group_name) == 0 && var.enabled ? 1 : 0 - name = join(var.delimiter, [module.label.id, var.option_group_version]) + name = join(var.delimiter, compact([module.label.id, var.option_group_version])) engine_name = var.engine major_engine_version = local.major_engine_version tags = module.label.tags @@ -121,6 +125,10 @@ resource "aws_db_subnet_group" "default" { name = module.label.id subnet_ids = var.subnet_ids tags = module.label.tags + + lifecycle { + create_before_destroy = true + } } resource "aws_security_group" "default" { @@ -137,6 +145,10 @@ resource "aws_security_group" "default" { } tags = module.label.tags + + lifecycle { + create_before_destroy = true + } } resource "aws_security_group_rule" "default_ingress" {