Skip to content

Commit 5ff50e8

Browse files
Merge pull request #22 from hbarros-caylent/CA-94-logs-cw
CA-94 adding cloudwatch logs support
2 parents 9619819 + 3427beb commit 5ff50e8

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Tamr Terraform Template Repo
22

3+
## v3.1.0 - November 3rd 2021
4+
* Adds variables `enabled_cloudwatch_logs_exports`, `param_log_min_duration_statement` and `param_log_statement` configuring the logs and its publishing to CloudWatch
5+
36
## v3.0.0 - July 27th 2021
47
* Updates default engine version to not specify a minor version
58
* Adds new variable `auto_minor_version_upgrade` to allow AWS to upgrade RDS minor versions

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.1.0

main.tf

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ resource "aws_db_parameter_group" "rds_postgres_pg" {
66
name = var.parameter_group_name
77
family = var.parameter_group_family
88
description = "TAMR RDS parameter group"
9-
tags = local.effective_tags
9+
parameter {
10+
name = "log_statement"
11+
value = var.param_log_statement
12+
}
13+
parameter {
14+
name = "log_min_duration_statement"
15+
value = var.param_log_min_duration_statement
16+
}
17+
tags = local.effective_tags
1018
}
1119

1220
resource "aws_db_subnet_group" "rds_postgres_subnet_group" {
@@ -46,6 +54,8 @@ resource "aws_db_instance" "rds_postgres" {
4654

4755
apply_immediately = var.apply_immediately
4856

57+
enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports ? ["postgresql", "upgrade"] : []
58+
4959
copy_tags_to_snapshot = var.copy_tags_to_snapshot
5060
tags = local.effective_tags
5161

outputs.tf

+8
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ output "rds_username" {
2828
output "rds_dbname" {
2929
value = aws_db_instance.rds_postgres.name
3030
}
31+
32+
output "cloudwatch_logs_path" {
33+
value = (
34+
var.enabled_cloudwatch_logs_exports ?
35+
format("/aws/rds/instance/%s/postgresql", aws_db_instance.rds_postgres.id)
36+
: ""
37+
)
38+
}

variables.tf

+18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ variable "parameter_group_name" {
2727
default = "rds-postgres-pg"
2828
}
2929

30+
variable "param_log_min_duration_statement" {
31+
description = "(ms) Sets the minimum execution time above which statements will be logged."
32+
type = string
33+
default = "-1"
34+
}
35+
36+
variable "param_log_statement" {
37+
description = "Sets the type of statements logged. Valid values are none, ddl, mod, all"
38+
type = string
39+
default = "none"
40+
}
41+
3042
variable "identifier_prefix" {
3143
description = "Identifier prefix for the RDS instance"
3244
type = string
@@ -154,3 +166,9 @@ variable "auto_minor_version_upgrade" {
154166
type = bool
155167
description = "Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window"
156168
}
169+
170+
variable "enabled_cloudwatch_logs_exports" {
171+
default = true
172+
type = bool
173+
description = "Indicates that postgresql logs will be configured to be sent automatically to Cloudwatch"
174+
}

0 commit comments

Comments
 (0)