Skip to content

DEV-15188 DEV-15189 - Makes performance insights and multi AZ configurable #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 7, 2022
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Tamr Terraform Template Repo

## v4.1.0 - September 1st 2022
* Adds support for configuring multiple AZs
* Adds support for configuring performance insights

## v4.0.1 - August 4th 2022
* Adjusts AWS provider constraints to allow newer versions

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ This terraform module will create:
| instance\_class | Instance class | `string` | `"db.m4.large"` | no |
| maintenance\_window | Maintenance window | `string` | `"sun:04:32-sun:05:02"` | no |
| max\_allocated\_storage | Max allocate storage | `number` | `1000` | no |
| multi\_az | Specifies if the RDS instance is multi-AZ. | `bool` | `true` | no |
| param\_log\_min\_duration\_statement | (ms) Sets the minimum execution time above which statements will be logged. | `string` | `"-1"` | no |
| param\_log\_statement | Sets the type of statements logged. Valid values are none, ddl, mod, all | `string` | `"none"` | no |
| parameter\_group\_family | The family of the DB parameter group | `string` | `"postgres12"` | no |
| parameter\_group\_name | The name of the rds parameter group | `string` | `"rds-postgres-pg"` | no |
| performance\_insights\_enabled | Specifies whether Performance Insights are enabled. | `bool` | `false` | no |
| performance\_insights\_retention\_period | The amount of time in days to retain Performance Insights data. Either 7 (7 days) or 731 (2 years). | `number` | `7` | no |
| postgres\_name | The name of the postgres database to create on the DB instance | `string` | `"tamr_rds_db"` | no |
| skip\_final\_snapshot | Skip final snapshot | `bool` | `true` | no |
| storage\_type | Storage type (e.g. gp2, io1) | `string` | `"gp2"` | no |
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1
4.1.0
1 change: 1 addition & 0 deletions examples/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ No provider.
| subnet\_ids | List of at least 2 subnets in different AZs for DB subnet group | `list(string)` | n/a | yes |
| vpc\_id | VPC ID of network. | `string` | n/a | yes |
| egress\_cidr\_blocks | CIDR blocks to attach to security groups for egress | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
| multi\_az | Specifies if the RDS instance is multi-AZ. | `bool` | `true` | no |
| tags | A map of tags to add to all resources created by this example. | `map(string)` | <pre>{<br> "Author": "Tamr",<br> "Environment": "Example"<br>}</pre> | no |

## Outputs
Expand Down
3 changes: 2 additions & 1 deletion examples/minimal/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module "rds_postgres" {
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=3.0.0"
# source = "git::https://github.com/Datatamer/terraform-aws-rds-postgres.git?ref=4.1.0"
source = "../.."

identifier_prefix = "${var.name_prefix}-example-rds-pg-"
Expand All @@ -11,6 +11,7 @@ module "rds_postgres" {
subnet_group_name = "${var.name_prefix}_example_subnet_group"
# Network requirement: DB subnet group needs a subnet in at least two Availability Zones
rds_subnet_ids = var.subnet_ids
multi_az = var.multi_az
security_group_ids = module.rds-postgres-sg.security_group_ids
tags = var.tags
}
Expand Down
6 changes: 6 additions & 0 deletions examples/minimal/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ variable "subnet_ids" {
description = "List of at least 2 subnets in different AZs for DB subnet group"
}

variable "multi_az" {
default = true
type = bool
description = "Specifies if the RDS instance is multi-AZ."
}

variable "name_prefix" {
description = "A string to prepend to names of resources created by this example"
}
Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ resource "aws_db_subnet_group" "rds_postgres_subnet_group" {
}

resource "aws_db_instance" "rds_postgres" {
# 'name' is deprecated in favor of 'db_name' after provider version 4.0.0
name = var.postgres_name

identifier_prefix = var.identifier_prefix
Expand All @@ -47,7 +48,7 @@ resource "aws_db_instance" "rds_postgres" {
port = var.db_port

db_subnet_group_name = aws_db_subnet_group.rds_postgres_subnet_group.name
multi_az = true
multi_az = var.multi_az
publicly_accessible = false
vpc_security_group_ids = var.security_group_ids
parameter_group_name = aws_db_parameter_group.rds_postgres_pg.name
Expand All @@ -64,6 +65,10 @@ resource "aws_db_instance" "rds_postgres" {
copy_tags_to_snapshot = var.copy_tags_to_snapshot
tags = local.effective_tags

# Performance Insights
performance_insights_enabled = var.performance_insights_enabled
performance_insights_retention_period = var.performance_insights_enabled ? var.performance_insights_retention_period : null

lifecycle {
ignore_changes = [password]
}
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,21 @@ variable "enabled_cloudwatch_logs_exports" {
type = bool
description = "Indicates that postgresql logs will be configured to be sent automatically to Cloudwatch"
}

variable "multi_az" {
default = true
type = bool
description = "Specifies if the RDS instance is multi-AZ."
}

variable "performance_insights_enabled" {
default = false
type = bool
description = "Specifies whether Performance Insights are enabled."
}

variable "performance_insights_retention_period" {
default = 7
type = number
description = "The amount of time in days to retain Performance Insights data. Either 7 (7 days) or 731 (2 years)."
}