Skip to content

Commit

Permalink
Fixing issue #4
Browse files Browse the repository at this point in the history
Fixes the issue “Existing RedShift subnet group not honored” (#4) where subnet groups / parameter groups were being incorrectly created.
  • Loading branch information
sc250024 committed Apr 26, 2018
1 parent b97aa0d commit e1ed24f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
locals {
redshift_subnet_group_name = "${coalesce(var.redshift_subnet_group_name, element(concat(aws_redshift_subnet_group.this.*.name, list("")), 0))}"
enable_create_redshift_subnet_group = "${var.redshift_subnet_group_name == "" ? 0 : 1}"
parameter_group_name = "${coalesce(var.parameter_group_name, element(concat(aws_redshift_parameter_group.this.*.id, list("")), 0))}"
enable_create_redshift_parameter_group = "${var.parameter_group_name == "" ? 0 : 1}"
}

resource "aws_redshift_cluster" "this" {
Expand Down Expand Up @@ -43,7 +41,7 @@ resource "aws_redshift_cluster" "this" {
}

resource "aws_redshift_parameter_group" "this" {
count = "${local.enable_create_redshift_parameter_group}"
count = "${var.parameter_group_name != "" ? 1 : 0}"

name = "${var.cluster_identifier}-${replace(var.cluster_parameter_group, ".", "-")}-custom-params"
family = "${var.cluster_parameter_group}"
Expand All @@ -55,7 +53,7 @@ resource "aws_redshift_parameter_group" "this" {
}

resource "aws_redshift_subnet_group" "this" {
count = "${local.enable_create_redshift_subnet_group}"
count = "${var.redshift_subnet_group_name != "" ? 0 : 1}"

name = "${var.cluster_identifier}"
description = "Redshift subnet group of ${var.cluster_identifier}"
Expand Down

0 comments on commit e1ed24f

Please sign in to comment.