redshift
Creates Redshift clusters with managed master passwords, subnet groups, parameter groups, enhanced VPC routing, and optional scheduled pause/resume/resize actions.
All clusters use manage_master_password = true to store credentials in Secrets Manager. Encryption is enabled by default with optional CMK. Enhanced VPC routing is enabled by default to ensure all traffic is routed through the VPC.
Usage
module "redshift" {
source = "hcassc.jfrog.io/iac-terraform-modules-virtual/database/redshift/aws"
version = "0.1.0"
subnet_groups = {
main = {
name = "prod-redshift"
subnet_ids = module.vpc.isolated_subnet_id_list
}
}
parameter_groups = {
main = {
name = "prod-redshift-params"
family = "redshift-1.0"
parameters = {
"enable_user_activity_logging" = "true"
"require_ssl" = "true"
"auto_analyze" = "true"
"search_path" = "$user, public"
}
}
}
clusters = {
main = {
cluster_identifier = "prod-analytics"
database_name = "analytics"
master_username = "admin"
node_type = "ra3.xlplus"
cluster_type = "multi-node"
number_of_nodes = 3
kms_key_id = module.kms.key_arn
vpc_security_group_ids = [module.security_groups.ids["redshift"]]
logging = {
enable = true
bucket_name = module.s3.bucket_ids["redshift-logs"]
s3_key_prefix = "redshift/prod/"
}
}
}
scheduled_actions = {
pause_nights = {
name = "prod-analytics-pause"
cluster_key = "main"
schedule = "cron(0 22 * * ? *)"
action_type = "pause"
iam_role_arn = aws_iam_role.redshift_scheduler.arn
}
resume_mornings = {
name = "prod-analytics-resume"
cluster_key = "main"
schedule = "cron(0 7 * * ? *)"
action_type = "resume"
iam_role_arn = aws_iam_role.redshift_scheduler.arn
}
}
tags = {
Environment = "prod"
Team = "data"
}
}
Requirements
| Name | Version |
|---|---|
| terraform | ~> 1.5 |
| aws | ~> 6.50 |
Providers
| Name | Version |
|---|---|
| aws | 6.50.0 |
Resources
| Name | Type |
|---|---|
| aws_redshift_cluster.this | resource |
| aws_redshift_logging.this | resource |
| aws_redshift_parameter_group.this | resource |
| aws_redshift_scheduled_action.this | resource |
| aws_redshift_subnet_group.this | resource |
Inputs
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| clusters | Map of Redshift cluster definitions | map(object({ cluster_identifier = string database_name = string master_username = string node_type = optional(string, "ra3.xlplus") cluster_type = optional(string, "multi-node") number_of_nodes = optional(number, 2) port = optional(number, 5439) allow_version_upgrade = optional(bool, true) publicly_accessible = optional(bool, false) encrypted = optional(bool, true) kms_key_id = optional(string, null) enhanced_vpc_routing = optional(bool, true) automated_snapshot_retention_period = optional(number, 7) preferred_maintenance_window = optional(string, "sun:05:00-sun:05:30") skip_final_snapshot = optional(bool, false) final_snapshot_identifier = optional(string, null) snapshot_cluster_identifier = optional(string, null) snapshot_identifier = optional(string, null) availability_zone = optional(string, null) availability_zone_relocation_enabled = optional(bool, false) iam_roles = optional(list(string), []) logging = optional(object({ enable = optional(bool, true) bucket_name = optional(string, null) s3_key_prefix = optional(string, "redshift/") }), null) subnet_group_name = optional(string, null) parameter_group_name = optional(string, null) vpc_security_group_ids = optional(list(string), []) })) | {} |
no |
| parameter_groups | Map of Redshift parameter group definitions | map(object({ name = string family = optional(string, "redshift-1.0") description = optional(string, "") parameters = optional(map(string), {}) })) | {} |
no |
| scheduled_actions | Map of Redshift scheduled action definitions (pause/resume) | map(object({ name = string cluster_key = string schedule = string action_type = string iam_role_arn = string pause = optional(bool, null) resize = optional(object({ node_type = string number_of_nodes = number cluster_type = string }), null) })) | {} |
no |
| subnet_groups | Map of Redshift subnet group definitions | map(object({ name = string description = optional(string, "") subnet_ids = list(string) })) | {} |
no |
| tags | Resource tags to apply to all resources | map(string) |
{} |
no |
Outputs
| Name | Description |
|---|---|
| cluster_arns | Map of cluster keys to Redshift cluster ARNs |
| cluster_dns_names | Map of cluster keys to Redshift cluster DNS names |
| cluster_endpoints | Map of cluster keys to Redshift cluster endpoints |
| cluster_ids | Map of cluster keys to Redshift cluster identifiers |
| cluster_ports | Map of cluster keys to Redshift cluster ports |
| master_password_secret_arns | Map of cluster keys to ARNs of the managed master password Secrets Manager secrets |
| parameter_group_ids | Map of parameter group keys to Redshift parameter group IDs |
| subnet_group_ids | Map of subnet group keys to Redshift subnet group IDs |