From abdce015c147fca94426141f29c773bd1262438b Mon Sep 17 00:00:00 2001 From: Jules Klakosz Date: Fri, 12 Feb 2021 18:28:54 +0100 Subject: [PATCH 1/2] Added redshift module --- envs/qa.tfvars | 2 ++ tf/2-variables.tf | 40 ++++++++++++++++++++++++++++++++++++++++ tf/4-outputs.tf | 11 +++++++++++ tf/redshift.tf | 17 +++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 tf/redshift.tf diff --git a/envs/qa.tfvars b/envs/qa.tfvars index 68f4041..d930fec 100644 --- a/envs/qa.tfvars +++ b/envs/qa.tfvars @@ -41,6 +41,8 @@ lambda_handler = "lambda.handler_test" lambda_runtime = "python3.8" // -- RDS rds_name = "boilerplate" +// -- Redshift +redshift_cluster_name = "boilerplate" // -- Route53 // -- VPC vpc_name = "boilerplate" diff --git a/tf/2-variables.tf b/tf/2-variables.tf index 9f93fe8..c2a0eb2 100644 --- a/tf/2-variables.tf +++ b/tf/2-variables.tf @@ -791,6 +791,46 @@ variable "final_snapshot_identifier" { default = "demodb" } +/* +// Redshift variables +*/ + +variable "redshift_cluster_name" { + type = string + description = "Name for redshift cluster." + default = "redshift-boilerplate" +} + +variable "redshift_node_type" { + type = string + description = "Node type for redshift cluster." + default = "dc1.large" +} + +variable "redshift_node_amount" { + type = number + description = "Node amount for redshift cluster." + default = 1 +} + +variable "redshift_db_name" { + type = string + description = "Database name for redshift cluster." + default = "db_name" +} + +variable "redshift_db_user" { + type = string + description = "Database user for redshift cluster." + default = "db_user" +} + +variable "redshift_db_master_password" { + type = string + description = "Database master password for redshift cluster." + default = "D8_m4st3r_p4ssword" +} + /* // Route53 variables */ diff --git a/tf/4-outputs.tf b/tf/4-outputs.tf index 1e8c2a4..9baefb7 100644 --- a/tf/4-outputs.tf +++ b/tf/4-outputs.tf @@ -223,6 +223,17 @@ output "route53" { } */ +/* +// Redshift outputs +*/ + +output "reshift" { + value = { + id = module.redshift.this_redshift_cluster_id + arn = module.redshift.this_redshift_cluster_arn + } +} + /* // SNS outputs */ diff --git a/tf/redshift.tf b/tf/redshift.tf new file mode 100644 index 0000000..de64396 --- /dev/null +++ b/tf/redshift.tf @@ -0,0 +1,17 @@ +module "redshift" { + source = "terraform-aws-modules/redshift/aws" + version = "~> 2.7" + + cluster_identifier = var.redshift_cluster_name + cluster_node_type = var.redshift_node_type + cluster_number_of_nodes = var.redshift_node_amount + + cluster_database_name = var.redshift_db_name + cluster_master_username = var.redshift_db_user + cluster_master_password = var.redshift_db_master_password + + final_snapshot_identifier = "1" + + subnets = module.vpc.private_subnets + vpc_security_group_ids = [module.vpc.default_security_group_id] +} From a7a03930decb6d1faf9c90d05280305207cc0287 Mon Sep 17 00:00:00 2001 From: Jules Klakosz Date: Fri, 12 Feb 2021 18:33:02 +0100 Subject: [PATCH 2/2] Fmt + added tags to redshift module --- tf/4-outputs.tf | 2 +- tf/redshift.tf | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tf/4-outputs.tf b/tf/4-outputs.tf index 9baefb7..4baa9cc 100644 --- a/tf/4-outputs.tf +++ b/tf/4-outputs.tf @@ -229,7 +229,7 @@ output "route53" { output "reshift" { value = { - id = module.redshift.this_redshift_cluster_id + id = module.redshift.this_redshift_cluster_id arn = module.redshift.this_redshift_cluster_arn } } diff --git a/tf/redshift.tf b/tf/redshift.tf index de64396..41ad2b9 100644 --- a/tf/redshift.tf +++ b/tf/redshift.tf @@ -12,6 +12,8 @@ module "redshift" { final_snapshot_identifier = "1" - subnets = module.vpc.private_subnets + subnets = module.vpc.private_subnets vpc_security_group_ids = [module.vpc.default_security_group_id] + + tags = local.tags }