Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4 & enhanced RedShift functionality #5

Merged
merged 11 commits into from
Apr 27, 2018
Merged

Fix #4 & enhanced RedShift functionality #5

merged 11 commits into from
Apr 27, 2018

Conversation

sc250024
Copy link
Contributor

@sc250024 sc250024 commented Apr 26, 2018

Fixes issue #4, and adds other functionality to the RedShift module.

Description

  • Fix for Existing RedShift subnet group not honored #4 => e1ed24f. The logic is this: A parameter group should not be created if parameter_group_name is not specified since RedShift will create a default parameter group for you. However, if redshift_subnet_group_name is not specified, then the resource redshift.aws_redshift_subnet_group.this should be created.
  • Enabling enhanced VPC routing => 019ff28
  • Calculating the value of cluster_type based on the number of nodes the user specifies => 0b0dc7d and fca695d
  • Added variable allow_version_upgrade => fc6c31e
  • Added variable final_snapshot_identifier => 7c86caa
  • Added S3 logging => 5792606

Motivation and Context

Initially I was attempting to solve #4, and noticed there was some other functionality I would like included in the module as well.

How Has This Been Tested?

Tested locally with AWS VPC creation of RedShift resources.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Fixes the issue “Existing RedShift subnet group not honored” (#4) where subnet groups / parameter groups were being incorrectly created.
- Updated the list of instance types
- Added `final_snapshot_identifier` functionality
- Adding `logging` block functionality
@sc250024 sc250024 changed the title Fix terraform-aws-redshift/issues/4 & enhanced RedShift functionality Fix #4 & enhanced RedShift functionality Apr 26, 2018
Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor comments here and there.

main.tf Outdated
@@ -55,7 +65,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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be == instead of !=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come to think of it, should we change the locals to be similar to the Terraform RDS module? https://github.com/terraform-aws-modules/terraform-aws-rds/blob/master/main.tf#L1-L6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, using locals is much better.

Copy link
Contributor Author

@sc250024 sc250024 Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way it was implemented before, using the blocks:

enable_create_redshift_subnet_group    = "${var.redshift_subnet_group_name == "" ? 0 : 1}"
enable_create_redshift_parameter_group = "${var.parameter_group_name == "" ? 0 : 1}"

Was actually was caused the problem. If you look at my logs in #4, for some reason, using enable_create_redshift_ the way it was written resulted in subnet groups being created even when a user specified an already existing subnet group.

In the RDS module, the difference is that the code block:

enable_create_db_subnet_group    = "${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}"
enable_create_db_parameter_group = "${var.parameter_group_name == "" ? var.create_db_parameter_group : 0}"

Has explicit create_db_* variables. Do we want equivalent create_redshift_parameter_group and create_redshift_subnet_group variables in this module?

main.tf Outdated
@@ -37,13 +38,22 @@ resource "aws_redshift_cluster" "this" {

tags = "${var.tags}"

# Enhanced VPC routing
enhanced_vpc_routing = "${var.enhanced_vpc_routing}"

lifecycle {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move tags and lifecycle arguments at the end as they were before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sc250024
Copy link
Contributor Author

sc250024 commented Apr 27, 2018

@antonbabenko My latest commit be8eeab restores most of the functionality for the locals enable_create_redshift_subnet_group and enable_create_redshift_parameter_group with one important change. The logic is this:

  • If parameter_group_name is blank, the default behavior should not be to create a custom parameter group since AWS will create a default one for you (named default.redshift-1.0). The resource aws_redshift_parameter_group.this should only be used when the user wants to specify a custom parameter group.

  • Conversely, if redshift_subnet_group_name is blank, the resource aws_redshift_subnet_group.this should be created (and thus, the user should also specify subnets) since a subnet group needs to exist in order to spin up the RedShift cluster.

Hopefully this resolves things, and can be merged now.

@antonbabenko
Copy link
Member

Took me some time to think about it and understand it. Good job! Merging now.

@antonbabenko antonbabenko merged commit c706e44 into terraform-aws-modules:master Apr 27, 2018
@antonbabenko
Copy link
Member

v1.1.0 has been released.

@sc250024 sc250024 deleted the enhanced-redshift-functionality branch April 27, 2018 21:23
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants