Skip to content

Commit 9cdbd6d

Browse files
authored
Merge pull request #34 from xoap-io/dev
fix: logging and performance metrics
2 parents 7103c89 + 337cffa commit 9cdbd6d

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,16 @@ Please be aware that this is mainly a copy operation which means all your curren
136136

137137
| Name | Description | Type | Default | Required |
138138
|------|-------------|------|---------|:--------:|
139-
| <a name="input_backup"></a> [backup](#input\_backup) | The backup configuration for the RDS instance | <pre>object({<br> enabled = bool<br> retention_days = number<br> })</pre> | n/a | yes |
140-
| <a name="input_context"></a> [context](#input\_context) | Default context for naming and tagging purpose | <pre>object({<br> organization = string<br> environment = string<br> account = string<br> product = string<br> tags = map(string)<br> })</pre> | n/a | yes |
139+
| <a name="input_backup"></a> [backup](#input\_backup) | The backup configuration for the RDS instance | <pre>object({<br/> enabled = bool<br/> retention_days = number<br/> })</pre> | n/a | yes |
140+
| <a name="input_backup_kms_key"></a> [backup\_kms\_key](#input\_backup\_kms\_key) | The backup kms key for AWS RDS | `string` | n/a | yes |
141+
| <a name="input_context"></a> [context](#input\_context) | Default context for naming and tagging purpose | <pre>object({<br/> organization = string<br/> environment = string<br/> account = string<br/> product = string<br/> tags = map(string)<br/> })</pre> | n/a | yes |
141142
| <a name="input_enable_performance_insights"></a> [enable\_performance\_insights](#input\_enable\_performance\_insights) | Whether to enable Performance Insights | `bool` | n/a | yes |
142-
| <a name="input_instance"></a> [instance](#input\_instance) | The RDS instance to create | <pre>object({<br> type = string<br> engine = string<br> engine_version = string<br> major_engine_version = string<br> family = string<br> multi_az = bool<br> publicly_accessible = bool<br> deletion_protection = bool<br> allow_upgrades = bool<br> port = number<br> })</pre> | n/a | yes |
143-
| <a name="input_logging"></a> [logging](#input\_logging) | The logging configuration for the RDS instance | <pre>object({<br> enabled = bool<br> types = set(string)<br> })</pre> | n/a | yes |
143+
| <a name="input_instance"></a> [instance](#input\_instance) | The RDS instance to create | <pre>object({<br/> type = string<br/> engine = string<br/> engine_version = string<br/> major_engine_version = string<br/> family = string<br/> multi_az = bool<br/> publicly_accessible = bool<br/> deletion_protection = bool<br/> allow_upgrades = bool<br/> port = number<br/> })</pre> | n/a | yes |
144+
| <a name="input_logging"></a> [logging](#input\_logging) | The logging configuration for the RDS instance | <pre>object({<br/> enabled = bool<br/> types = set(string)<br/> })</pre> | n/a | yes |
144145
| <a name="input_name"></a> [name](#input\_name) | The name of the RDS instance | `string` | n/a | yes |
145146
| <a name="input_parameters"></a> [parameters](#input\_parameters) | The parameters to pass to the RDS instance | `map(string)` | n/a | yes |
146-
| <a name="input_storage"></a> [storage](#input\_storage) | The storage configuration for the RDS instance | <pre>object({<br> max_allocated_storage = number<br> allocated_storage = number<br> kms_arn = string<br> })</pre> | n/a | yes |
147-
| <a name="input_vpc"></a> [vpc](#input\_vpc) | The VPC to create the RDS instance in | <pre>object({<br> id = string<br> subnets = list(string)<br> security_groups = list(string)<br> })</pre> | n/a | yes |
147+
| <a name="input_storage"></a> [storage](#input\_storage) | The storage configuration for the RDS instance | <pre>object({<br/> max_allocated_storage = number<br/> allocated_storage = number<br/> kms_arn = string<br/> })</pre> | n/a | yes |
148+
| <a name="input_vpc"></a> [vpc](#input\_vpc) | The VPC to create the RDS instance in | <pre>object({<br/> id = string<br/> subnets = list(string)<br/> security_groups = list(string)<br/> })</pre> | n/a | yes |
148149

149150
## Outputs
150151

main.tf

+26-24
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,36 @@ resource "aws_db_option_group" "this" {
5050
}
5151
}
5252
resource "aws_db_instance" "this" {
53-
engine = var.instance.engine
54-
engine_version = var.instance.engine_version
55-
instance_class = var.instance.type
56-
identifier = module.this_label.id
57-
username = local.admin_user
58-
password = random_password.this.result
59-
skip_final_snapshot = false
60-
allocated_storage = var.storage.allocated_storage
61-
max_allocated_storage = var.storage.max_allocated_storage
62-
storage_encrypted = var.storage.kms_arn != ""
63-
kms_key_id = var.storage.kms_arn
64-
final_snapshot_identifier = module.this_label_snapshot.id
65-
multi_az = var.instance.multi_az
66-
publicly_accessible = var.instance.publicly_accessible
67-
deletion_protection = var.instance.deletion_protection
68-
auto_minor_version_upgrade = var.instance.allow_upgrades
69-
allow_major_version_upgrade = true
70-
db_subnet_group_name = aws_db_subnet_group.this.id
71-
parameter_group_name = aws_db_parameter_group.this.id
72-
option_group_name = aws_db_option_group.this.id
73-
maintenance_window = var.backup.enabled == true ? "Mon:00:00-Mon:03:00" : null
74-
backup_window = var.backup.enabled == true ? "03:00-06:00" : null
75-
backup_retention_period = var.backup.enabled == true ? var.backup.retention_days : 0
53+
engine = var.instance.engine
54+
engine_version = var.instance.engine_version
55+
instance_class = var.instance.type
56+
identifier = module.this_label.id
57+
username = local.admin_user
58+
password = random_password.this.result
59+
skip_final_snapshot = false
60+
allocated_storage = var.storage.allocated_storage
61+
max_allocated_storage = var.storage.max_allocated_storage
62+
storage_encrypted = var.storage.kms_arn != ""
63+
kms_key_id = var.storage.kms_arn
64+
final_snapshot_identifier = module.this_label_snapshot.id
65+
multi_az = var.instance.multi_az
66+
publicly_accessible = var.instance.publicly_accessible
67+
deletion_protection = var.instance.deletion_protection
68+
auto_minor_version_upgrade = var.instance.allow_upgrades
69+
allow_major_version_upgrade = true
70+
db_subnet_group_name = aws_db_subnet_group.this.id
71+
parameter_group_name = aws_db_parameter_group.this.id
72+
option_group_name = aws_db_option_group.this.id
73+
maintenance_window = var.backup.enabled == true ? "Mon:00:00-Mon:03:00" : null
74+
backup_window = var.backup.enabled == true ? "03:00-06:00" : null
75+
backup_retention_period = var.backup.enabled == true ? var.backup.retention_days : 0
76+
7677
vpc_security_group_ids = var.vpc.security_groups
7778
performance_insights_enabled = var.enable_performance_insights
7879
apply_immediately = true
7980
iam_database_authentication_enabled = true
80-
enabled_cloudwatch_logs_exports = var.logging.types
81+
enabled_cloudwatch_logs_exports = var.instance.engine == "mariadb" ? ["audit", "error", "general", "slowquery"] : var.instance.engine == "postgres" ? ["postgresql", "upgrade"] : []
82+
8183
tags = {
8284
Name = module.this_label.id
8385
Restriction = "Restricted"

variables.tf

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ variable "storage" {
3333
})
3434
description = "The storage configuration for the RDS instance"
3535
}
36+
variable "backup_kms_key" {
37+
type = string
38+
description = "The backup kms key for AWS RDS"
39+
}
3640
variable "backup" {
3741
type = object({
3842
enabled = bool

0 commit comments

Comments
 (0)