Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ resource "aws_redshift_cluster" "default" {
iam_roles = var.iam_roles
allow_version_upgrade = var.allow_version_upgrade

logging {
enable = var.logging_enabled
bucket_name = var.logging_bucket_name
s3_key_prefix = var.logging_s3_key_prefix
}

depends_on = [
aws_redshift_subnet_group.default,
aws_redshift_parameter_group.default
]

tags = module.this.tags

lifecycle {
ignore_changes = [logging]
}
}

resource "aws_redshift_subnet_group" "default" {
Expand Down Expand Up @@ -76,3 +74,14 @@ resource "aws_redshift_parameter_group" "default" {

tags = module.this.tags
}

resource "aws_redshift_logging" "default" {
count = local.enabled && var.logging_enabled ? 1 : 0

cluster_identifier = aws_redshift_cluster.default[0].id
log_destination_type = var.logging_log_destination_type
log_exports = var.logging_log_exports

bucket_name = var.logging_bucket_name
s3_key_prefix = var.logging_s3_key_prefix
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ variable "logging_enabled" {
description = "If true, enables logging information such as queries and connection attempts, for the specified Amazon Redshift cluster"
}

variable "logging_log_destination_type" {
type = string
default = null
description = "Log destination type for the Redshift cluster ('s3' or 'cloudwatch')."
}

variable "logging_log_exports" {
type = list(string)
default = []
description = "Log destination types for the cluster (one or more of 'connectionlog', 'useractivitylog', 'userlog')."
}

variable "logging_bucket_name" {
type = string
default = null
Expand Down