Skip to content

Commit

Permalink
Merge pull request #5 from sc250024/enhanced-redshift-functionality
Browse files Browse the repository at this point in the history
Fix #4 & enhanced RedShift functionality
  • Loading branch information
antonbabenko authored Apr 27, 2018
2 parents b97aa0d + be8eeab commit c706e44
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
15 changes: 14 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +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}"
enable_create_redshift_subnet_group = "${var.redshift_subnet_group_name == "" ? 1 : 0}"
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}"
}
Expand All @@ -10,6 +10,7 @@ resource "aws_redshift_cluster" "this" {
cluster_version = "${var.cluster_version}"
node_type = "${var.cluster_node_type}"
number_of_nodes = "${var.cluster_number_of_nodes}"
cluster_type = "${var.cluster_number_of_nodes > 1 ? "multi-node" : "single-node" }"
database_name = "${var.cluster_database_name}"
master_username = "${var.cluster_master_username}"
master_password = "${var.cluster_master_password}"
Expand All @@ -24,9 +25,11 @@ resource "aws_redshift_cluster" "this" {
publicly_accessible = "${var.publicly_accessible}"

# Snapshots and backups
final_snapshot_identifier = "${var.final_snapshot_identifier}"
skip_final_snapshot = "${var.skip_final_snapshot}"
automated_snapshot_retention_period = "${var.automated_snapshot_retention_period }"
preferred_maintenance_window = "${var.preferred_maintenance_window}"
allow_version_upgrade = "${var.allow_version_upgrade}"

# IAM Roles
iam_roles = ["${var.cluster_iam_roles}"]
Expand All @@ -35,6 +38,16 @@ resource "aws_redshift_cluster" "this" {
encrypted = "${var.encrypted}"
kms_key_id = "${var.kms_key_id}"

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

# Logging
logging {
enable = "${var.enable_logging}"
bucket_name = "${var.logging_bucket_name}"
s3_key_prefix = "${var.logging_s3_key_prefix}"
}

tags = "${var.tags}"

lifecycle {
Expand Down
36 changes: 34 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ variable "cluster_version" {
variable "cluster_node_type" {
description = "Node Type of Redshift cluster"

# Valid Values: ds1.xlarge | ds1.8xlarge | ds2.xlarge | ds2.8xlarge | dc1.large | dc1.8xlarge.
# Valid Values: dc1.large | dc1.8xlarge | dc2.large | dc2.8xlarge | ds2.xlarge | ds2.8xlarge.
# http://docs.aws.amazon.com/cli/latest/reference/redshift/create-cluster.html
}

variable "cluster_number_of_nodes" {
description = "Number of Node in the cluster"
description = "Number of nodes in the cluster (values greater than 1 will trigger 'cluster_type' of 'multi-node')"
default = 3
}

Expand Down Expand Up @@ -76,6 +76,12 @@ variable "vpc_security_group_ids" {
default = []
}

# Snapshots and maintenance windows
variable "final_snapshot_identifier" {
description = "(Optional) The identifier of the final snapshot that is to be created immediately before deleting the cluster. If this parameter is provided, 'skip_final_snapshot' must be false."
default = false
}

variable "skip_final_snapshot" {
description = "If true (default), no snapshot will be made before deleting DB"
default = true
Expand All @@ -91,6 +97,22 @@ variable "automated_snapshot_retention_period" {
default = 0
}

# Logging
variable "enable_logging" {
description = "Enables logging information such as queries and connection attempts, for the specified Amazon Redshift cluster."
default = false
}

variable "logging_bucket_name" {
description = "(Optional, required when enable_logging is true) The name of an existing S3 bucket where the log files are to be stored. Must be in the same region as the cluster and the cluster must have read bucket and put object permissions."
default = false
}

variable "logging_s3_key_prefix" {
description = "(Optional) The prefix applied to the log file names."
default = false
}

variable "wlm_json_configuration" {
default = "[{\"query_concurrency\": 5}]"
}
Expand All @@ -109,3 +131,13 @@ variable "kms_key_id" {
description = "(Optional) The ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true."
default = ""
}

variable "enhanced_vpc_routing" {
description = "(Optional) If true, enhanced VPC routing is enabled."
default = false
}

variable "allow_version_upgrade" {
description = "(Optional) If true, major version upgrades can be applied during the maintenance window to the Amazon Redshift engine that is running on the cluster."
default = true
}

0 comments on commit c706e44

Please sign in to comment.