Skip to content

Commit 73e33fe

Browse files
authored
feat: Support cloudwatch_log_group_tags parameter (#571)
Similar to `db_parameter_group_tags`, sometimes it is necessary to configure additional tags on CloudWatch log groups only.
1 parent 220cc85 commit 73e33fe

File tree

8 files changed

+22
-1
lines changed

8 files changed

+22
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ No resources.
248248
| <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 |
249249
| <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 |
250250
| <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 |
251+
| <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 |
251252
| <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 |
252253
| <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 |
253254
| <a name="input_create_db_instance"></a> [create\_db\_instance](#input\_create\_db\_instance) | Whether to create a database instance | `bool` | `true` | no |

examples/complete-mysql/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ module "db" {
8282
db_subnet_group_tags = {
8383
"Sensitive" = "high"
8484
}
85+
cloudwatch_log_group_tags = {
86+
"Sensitive" = "high"
87+
}
8588
}
8689

8790
module "db_default" {

examples/complete-postgres/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ module "db" {
9797
db_parameter_group_tags = {
9898
"Sensitive" = "low"
9999
}
100+
cloudwatch_log_group_tags = {
101+
"Sensitive" = "high"
102+
}
100103
}
101104

102105
module "db_default" {

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ module "db_instance" {
149149
cloudwatch_log_group_kms_key_id = var.cloudwatch_log_group_kms_key_id
150150
cloudwatch_log_group_skip_destroy = var.cloudwatch_log_group_skip_destroy
151151
cloudwatch_log_group_class = var.cloudwatch_log_group_class
152+
cloudwatch_log_group_tags = var.cloudwatch_log_group_tags
152153

153154
timeouts = var.timeouts
154155

modules/db_instance/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ No modules.
5151
| <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 |
5252
| <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 |
5353
| <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 |
54+
| <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 |
5455
| <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 |
5556
| <a name="input_create"></a> [create](#input\_create) | Whether to create this resource or not? | `bool` | `true` | no |
5657
| <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 |

modules/db_instance/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ resource "aws_cloudwatch_log_group" "this" {
163163
skip_destroy = var.cloudwatch_log_group_skip_destroy
164164
log_group_class = var.cloudwatch_log_group_class
165165

166-
tags = var.tags
166+
tags = merge(var.tags, var.cloudwatch_log_group_tags)
167167
}
168168

169169
################################################################################

modules/db_instance/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ variable "cloudwatch_log_group_class" {
478478
default = null
479479
}
480480

481+
variable "cloudwatch_log_group_tags" {
482+
description = "Additional tags for the CloudWatch log group(s)"
483+
type = map(string)
484+
default = {}
485+
}
486+
481487
################################################################################
482488
# Managed Secret Rotation
483489
################################################################################

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,12 @@ variable "cloudwatch_log_group_class" {
605605
default = null
606606
}
607607

608+
variable "cloudwatch_log_group_tags" {
609+
description = "Additional tags for the CloudWatch log group(s)"
610+
type = map(string)
611+
default = {}
612+
}
613+
608614
variable "putin_khuylo" {
609615
description = "Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!"
610616
type = bool

0 commit comments

Comments
 (0)