Skip to content

Commit 37701a0

Browse files
authored
feat: Add variable for applying tags to the log_forwarder bucket (#41)
1 parent 3920c11 commit 37701a0

File tree

7 files changed

+17
-1
lines changed

7 files changed

+17
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
131131
| <a name="input_kms_alias"></a> [kms\_alias](#input\_kms\_alias) | Alias of KMS key used to encrypt the Datadog API keys - must start with `alias/` | `string` | n/a | yes |
132132
| <a name="input_log_forwarder_architectures"></a> [log\_forwarder\_architectures](#input\_log\_forwarder\_architectures) | Instruction set architecture for your Lambda function. Valid values are `["x86_64"]` and `["arm64"]`. Default is `["x86_64"]` | `list(string)` | <pre>[<br> "x86_64"<br>]</pre> | no |
133133
| <a name="input_log_forwarder_bucket_prefix"></a> [log\_forwarder\_bucket\_prefix](#input\_log\_forwarder\_bucket\_prefix) | S3 object key prefix to prepend to zip archive name | `string` | `""` | no |
134+
| <a name="input_log_forwarder_bucket_tags"></a> [log\_forwarder\_bucket\_tags](#input\_log\_forwarder\_bucket\_tags) | A map of tags to apply to the log forwarder bucket | `map(any)` | `{}` | no |
134135
| <a name="input_log_forwarder_environment_variables"></a> [log\_forwarder\_environment\_variables](#input\_log\_forwarder\_environment\_variables) | A map of environment variables for the log forwarder lambda function | `map(string)` | `{}` | no |
135136
| <a name="input_log_forwarder_kms_key_arn"></a> [log\_forwarder\_kms\_key\_arn](#input\_log\_forwarder\_kms\_key\_arn) | KMS key that is used to encrypt environment variables. If this configuration is not provided when environment variables are in use, AWS Lambda uses a default service key | `string` | `null` | no |
136137
| <a name="input_log_forwarder_lambda_tags"></a> [log\_forwarder\_lambda\_tags](#input\_log\_forwarder\_lambda\_tags) | A map of tags to apply to the log forwarder lambda function | `map(string)` | `{}` | no |

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ module "default" {
7373
log_forwarder_role_tags = { ForwarderRole = true }
7474
log_forwarder_s3_log_bucket_arns = [module.log_bucket_1.s3_bucket_arn, module.log_bucket_2.s3_bucket_arn]
7575
log_forwarder_tags = { LogForwarder = true }
76+
log_forwarder_bucket_tags = { ForwarderBucket = true }
7677

7778
rds_em_forwarder_name = "complete-datadog-rds-forwarder"
7879
rds_em_forwarder_memory_size = 512

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module "log_forwarder" {
3131
create_bucket = var.create_bucket
3232
bucket_name = var.bucket_name
3333
bucket_prefix = var.log_forwarder_bucket_prefix
34+
bucket_tags = var.log_forwarder_bucket_tags
3435
bucket_attach_deny_insecure_transport_policy = var.bucket_attach_deny_insecure_transport_policy
3536
bucket_encryption_settings = var.bucket_encryption_settings
3637

modules/log_forwarder/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ module "datadog_log_forwarder" {
8484
| <a name="input_bucket_encryption_settings"></a> [bucket\_encryption\_settings](#input\_bucket\_encryption\_settings) | S3 bucket server side encryption settings | `map(string)` | <pre>{<br> "sse_algorithm": "AES256"<br>}</pre> | no |
8585
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Forwarder S3 bucket name | `string` | `""` | no |
8686
| <a name="input_bucket_prefix"></a> [bucket\_prefix](#input\_bucket\_prefix) | S3 object key prefix to prepend to zip archive name | `string` | `""` | no |
87+
| <a name="input_bucket_tags"></a> [bucket\_tags](#input\_bucket\_tags) | A map of tags to apply to the bucket | `map(string)` | `{}` | no |
8788
| <a name="input_create"></a> [create](#input\_create) | Controls whether the forwarder resources should be created | `bool` | `true` | no |
8889
| <a name="input_create_bucket"></a> [create\_bucket](#input\_create\_bucket) | Controls whether an S3 bucket should be created for the forwarder | `bool` | `true` | no |
8990
| <a name="input_create_role"></a> [create\_role](#input\_create\_role) | Controls whether an IAM role is created for the forwarder | `bool` | `true` | no |

modules/log_forwarder/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module "this_s3_bucket" {
4747
}
4848
}
4949

50-
tags = var.tags
50+
tags = merge(var.tags, var.bucket_tags)
5151
}
5252

5353
################################################################################

modules/log_forwarder/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ variable "bucket_prefix" {
6363
default = ""
6464
}
6565

66+
variable "bucket_tags" {
67+
description = "A map of tags to apply to the bucket"
68+
type = map(string)
69+
default = {}
70+
}
71+
6672
variable "s3_zip_storage_class" {
6773
description = "Specifies the desired Storage Class for the zip object. Can be either `STANDARD`, `REDUCED_REDUNDANCY`, `ONEZONE_IA`, `INTELLIGENT_TIERING`, or `STANDARD_IA`"
6874
type = string

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ variable "log_forwarder_bucket_prefix" {
6868
default = ""
6969
}
7070

71+
variable "log_forwarder_bucket_tags" {
72+
description = "A map of tags to apply to the log forwarder bucket"
73+
type = map(any)
74+
default = {}
75+
}
76+
7177
variable "log_forwarder_s3_zip_storage_class" {
7278
description = "Specifies the desired Storage Class for the zip object. Can be either `STANDARD`, `REDUCED_REDUNDANCY`, `ONEZONE_IA`, `INTELLIGENT_TIERING`, or `STANDARD_IA`"
7379
type = string

0 commit comments

Comments
 (0)