Skip to content

Commit

Permalink
feat: Support cloudwatch_log_group_tags parameter (#571)
Browse files Browse the repository at this point in the history
Similar to `db_parameter_group_tags`, sometimes it is necessary to
configure additional tags on CloudWatch log groups only.
  • Loading branch information
take-five authored Oct 16, 2024
1 parent 220cc85 commit 73e33fe
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ No resources.
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | The number of days to retain CloudWatch logs for the DB instance | `number` | `7` | no |
| <a name="input_cloudwatch_log_group_skip_destroy"></a> [cloudwatch\_log\_group\_skip\_destroy](#input\_cloudwatch\_log\_group\_skip\_destroy) | Set to true if you do not wish the log group (and any logs it may contain) to be deleted at destroy time, and instead just remove the log group from the Terraform state | `bool` | `null` | no |
| <a name="input_cloudwatch_log_group_tags"></a> [cloudwatch\_log\_group\_tags](#input\_cloudwatch\_log\_group\_tags) | Additional tags for the CloudWatch log group(s) | `map(string)` | `{}` | no |
| <a name="input_copy_tags_to_snapshot"></a> [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | On delete, copy all Instance tags to the final snapshot | `bool` | `false` | no |
| <a name="input_create_cloudwatch_log_group"></a> [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a CloudWatch log group is created for each `enabled_cloudwatch_logs_exports` | `bool` | `false` | no |
| <a name="input_create_db_instance"></a> [create\_db\_instance](#input\_create\_db\_instance) | Whether to create a database instance | `bool` | `true` | no |
Expand Down
3 changes: 3 additions & 0 deletions examples/complete-mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ module "db" {
db_subnet_group_tags = {
"Sensitive" = "high"
}
cloudwatch_log_group_tags = {
"Sensitive" = "high"
}
}

module "db_default" {
Expand Down
3 changes: 3 additions & 0 deletions examples/complete-postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ module "db" {
db_parameter_group_tags = {
"Sensitive" = "low"
}
cloudwatch_log_group_tags = {
"Sensitive" = "high"
}
}

module "db_default" {
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ module "db_instance" {
cloudwatch_log_group_kms_key_id = var.cloudwatch_log_group_kms_key_id
cloudwatch_log_group_skip_destroy = var.cloudwatch_log_group_skip_destroy
cloudwatch_log_group_class = var.cloudwatch_log_group_class
cloudwatch_log_group_tags = var.cloudwatch_log_group_tags

timeouts = var.timeouts

Expand Down
1 change: 1 addition & 0 deletions modules/db_instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ No modules.
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | The ARN of the KMS Key to use when encrypting log data | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | The number of days to retain CloudWatch logs for the DB instance | `number` | `7` | no |
| <a name="input_cloudwatch_log_group_skip_destroy"></a> [cloudwatch\_log\_group\_skip\_destroy](#input\_cloudwatch\_log\_group\_skip\_destroy) | Set to true if you do not wish the log group (and any logs it may contain) to be deleted at destroy time, and instead just remove the log group from the Terraform state | `bool` | `null` | no |
| <a name="input_cloudwatch_log_group_tags"></a> [cloudwatch\_log\_group\_tags](#input\_cloudwatch\_log\_group\_tags) | Additional tags for the CloudWatch log group(s) | `map(string)` | `{}` | no |
| <a name="input_copy_tags_to_snapshot"></a> [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | On delete, copy all Instance tags to the final snapshot | `bool` | `false` | no |
| <a name="input_create"></a> [create](#input\_create) | Whether to create this resource or not? | `bool` | `true` | no |
| <a name="input_create_cloudwatch_log_group"></a> [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a CloudWatch log group is created for each `enabled_cloudwatch_logs_exports` | `bool` | `false` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/db_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ resource "aws_cloudwatch_log_group" "this" {
skip_destroy = var.cloudwatch_log_group_skip_destroy
log_group_class = var.cloudwatch_log_group_class

tags = var.tags
tags = merge(var.tags, var.cloudwatch_log_group_tags)
}

################################################################################
Expand Down
6 changes: 6 additions & 0 deletions modules/db_instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ variable "cloudwatch_log_group_class" {
default = null
}

variable "cloudwatch_log_group_tags" {
description = "Additional tags for the CloudWatch log group(s)"
type = map(string)
default = {}
}

################################################################################
# Managed Secret Rotation
################################################################################
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,12 @@ variable "cloudwatch_log_group_class" {
default = null
}

variable "cloudwatch_log_group_tags" {
description = "Additional tags for the CloudWatch log group(s)"
type = map(string)
default = {}
}

variable "putin_khuylo" {
description = "Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!"
type = bool
Expand Down

0 comments on commit 73e33fe

Please sign in to comment.