Skip to content

Commit

Permalink
fix: Add support for out-of-band Performance Insight's being added (#114
Browse files Browse the repository at this point in the history
)

* fix: Add support for out of band Performance Insight's being added
  • Loading branch information
zacharyblasczyk authored Jul 28, 2023
1 parent fb23caa commit 210237d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ You will not be able to upgrade directly from `1.21` to `1.24`.
| <a name="input_database_instance_class"></a> [database\_instance\_class](#input\_database\_instance\_class) | Instance type to use by database master instance. | `string` | `"db.r5.large"` | no |
| <a name="input_database_master_username"></a> [database\_master\_username](#input\_database\_master\_username) | Specifies the master\_username value to set for the database | `string` | `"wandb"` | no |
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | Specifies the name of the database | `string` | `"wandb_local"` | no |
| <a name="input_database_performance_insights_kms_key_arn"></a> [database\_performance\_insights\_kms\_key\_arn](#input\_database\_performance\_insights\_kms\_key\_arn) | Specifies an existing KMS key ARN to encrypt the performance insights data if performance\_insights\_enabled is was enabled out of band | `string` | n/a | yes |
| <a name="input_database_snapshot_identifier"></a> [database\_snapshot\_identifier](#input\_database\_snapshot\_identifier) | Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot | `string` | `null` | no |
| <a name="input_database_sort_buffer_size"></a> [database\_sort\_buffer\_size](#input\_database\_sort\_buffer\_size) | Specifies the sort\_buffer\_size value to set for the database | `number` | `67108864` | no |
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | If the instance should have deletion protection enabled. The database / S3 can't be deleted when this value is set to `true`. | `bool` | `true` | no |
Expand Down
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ locals {
module "database" {
source = "./modules/database"

namespace = var.namespace
kms_key_arn = local.kms_key_arn
namespace = var.namespace
kms_key_arn = local.kms_key_arn
performance_insights_kms_key_arn = var.database_performance_insights_kms_key_arn_kms_key_arn

database_name = var.database_name
master_username = var.database_master_username
Expand Down
2 changes: 1 addition & 1 deletion modules/app_eks/iam-roles.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_iam_role" "node" {
name = "${var.namespace}-node"
assume_role_policy = data.aws_iam_policy_document.node_assume.json

// todo: refactor --> v1.16.3
inline_policy {}
}
Expand Down
56 changes: 28 additions & 28 deletions modules/database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,39 @@ module "aurora" {
source = "terraform-aws-modules/rds-aurora/aws"
version = "6.2.0"

allow_major_version_upgrade = true
allowed_cidr_blocks = var.allowed_cidr_blocks
apply_immediately = true
autoscaling_enabled = false
backup_retention_period = var.backup_retention_period
create_db_subnet_group = var.create_db_subnet_group
create_random_password = false
create_security_group = true
database_name = var.database_name
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.default.id
db_parameter_group_name = aws_db_parameter_group.default.id
db_subnet_group_name = var.db_subnet_group_name
deletion_protection = var.deletion_protection
enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"]
engine = "aurora-mysql"
engine_version = var.engine_version
iam_database_authentication_enabled = false
iam_role_force_detach_policies = true
iam_role_name = "${var.namespace}-aurora-monitoring"
instance_class = var.instance_class
instances = { 1 = {} }
kms_key_id = var.kms_key_arn
master_password = local.master_password
master_username = var.master_username
monitoring_interval = 15
name = var.namespace
allow_major_version_upgrade = true
allowed_cidr_blocks = var.allowed_cidr_blocks
apply_immediately = true
autoscaling_enabled = false
backup_retention_period = var.backup_retention_period
create_db_subnet_group = var.create_db_subnet_group
create_random_password = false
create_security_group = true
database_name = var.database_name
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.default.id
db_parameter_group_name = aws_db_parameter_group.default.id
db_subnet_group_name = var.db_subnet_group_name
deletion_protection = var.deletion_protection
enabled_cloudwatch_logs_exports = ["audit", "error", "general", "slowquery"]
engine = "aurora-mysql"
engine_version = var.engine_version
iam_database_authentication_enabled = false
iam_role_force_detach_policies = true
iam_role_name = "${var.namespace}-aurora-monitoring"
instance_class = var.instance_class
instances = { 1 = {} }
kms_key_id = var.kms_key_arn
master_password = local.master_password
master_username = var.master_username
monitoring_interval = 15
name = var.namespace
////////////////////////////////////////////////////////////////////////////////////////
// !!! note on performance insights !!!
// AWS offers 7 days of performance insights free. keeping them after this period
// incurs a per-vcpu cost. so we can keep them for 7 days and they're free
////////////////////////////////////////////////////////////////////////////////////////
performance_insights_enabled = true
performance_insights_kms_key_id = var.kms_key_arn
performance_insights_kms_key_id = var.performance_insights_kms_key_arn == "" ? var.kms_key_arn : var.database_performance_insights_kms_key_arn
performance_insights_retention_period = 7
preferred_backup_window = var.preferred_backup_window
preferred_maintenance_window = var.preferred_maintenance_window
Expand All @@ -141,5 +141,5 @@ module "aurora" {
subnets = var.subnets
vpc_id = var.vpc_id


}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ variable "database_innodb_lru_scan_depth" {
default = 128
}

variable "database_performance_insights_kms_key_arn" {
description = "Specifies an existing KMS key ARN to encrypt the performance insights data if performance_insights_enabled is was enabled out of band"
type = string
}

##########################################
# DNS #
##########################################
Expand Down

0 comments on commit 210237d

Please sign in to comment.