From 8f97707f6ea9aa3d382106a4917a0ddd1c3ec3e2 Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Fri, 22 Mar 2024 12:54:59 +0100 Subject: [PATCH] fix: Fixed constant drift with Lambda logging configuration (#551) --- .pre-commit-config.yaml | 31 +++++++++++++++---------------- README.md | 4 ++-- main.tf | 4 ++-- variables.tf | 4 ++-- wrappers/main.tf | 4 ++-- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c0a310c..299504fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,27 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.88.0 + rev: v1.88.2 hooks: - id: terraform_fmt - id: terraform_wrapper_module_for_each - id: terraform_docs args: - - '--args=--lockfile=false' + - "--args=--lockfile=false" - id: terraform_tflint args: - - '--args=--only=terraform_deprecated_interpolation' - - '--args=--only=terraform_deprecated_index' - - '--args=--only=terraform_unused_declarations' - - '--args=--only=terraform_comment_syntax' - - '--args=--only=terraform_documented_outputs' - - '--args=--only=terraform_documented_variables' - - '--args=--only=terraform_typed_variables' - - '--args=--only=terraform_module_pinned_source' - - '--args=--only=terraform_naming_convention' - - '--args=--only=terraform_required_version' - - '--args=--only=terraform_required_providers' - - '--args=--only=terraform_standard_module_structure' - - '--args=--only=terraform_workspace_remote' - - '--args=--only=terraform_unused_required_providers' + - "--args=--only=terraform_deprecated_interpolation" + - "--args=--only=terraform_deprecated_index" + - "--args=--only=terraform_unused_declarations" + - "--args=--only=terraform_comment_syntax" + - "--args=--only=terraform_documented_outputs" + - "--args=--only=terraform_documented_variables" + - "--args=--only=terraform_typed_variables" + - "--args=--only=terraform_module_pinned_source" + - "--args=--only=terraform_naming_convention" + - "--args=--only=terraform_required_version" + - "--args=--only=terraform_required_providers" + - "--args=--only=terraform_standard_module_structure" + - "--args=--only=terraform_workspace_remote" - id: terraform_validate - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 diff --git a/README.md b/README.md index 21f2884a..90640480 100644 --- a/README.md +++ b/README.md @@ -810,10 +810,10 @@ No modules. | [layers](#input\_layers) | List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. | `list(string)` | `null` | no | | [license\_info](#input\_license\_info) | License info for your Lambda Layer. Eg, MIT or full url of a license. | `string` | `""` | no | | [local\_existing\_package](#input\_local\_existing\_package) | The absolute path to an existing zip-file to use | `string` | `null` | no | -| [logging\_application\_log\_level](#input\_logging\_application\_log\_level) | The application log level of the Lambda Function. Valid values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", or "FATAL". | `string` | `null` | no | +| [logging\_application\_log\_level](#input\_logging\_application\_log\_level) | The application log level of the Lambda Function. Valid values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", or "FATAL". | `string` | `"INFO"` | no | | [logging\_log\_format](#input\_logging\_log\_format) | The log format of the Lambda Function. Valid values are "JSON" or "Text". | `string` | `"Text"` | no | | [logging\_log\_group](#input\_logging\_log\_group) | The CloudWatch log group to send logs to. | `string` | `null` | no | -| [logging\_system\_log\_level](#input\_logging\_system\_log\_level) | The system log level of the Lambda Function. Valid values are "DEBUG", "INFO", or "WARN". | `string` | `null` | no | +| [logging\_system\_log\_level](#input\_logging\_system\_log\_level) | The system log level of the Lambda Function. Valid values are "DEBUG", "INFO", or "WARN". | `string` | `"INFO"` | no | | [maximum\_event\_age\_in\_seconds](#input\_maximum\_event\_age\_in\_seconds) | Maximum age of a request that Lambda sends to a function for processing in seconds. Valid values between 60 and 21600. | `number` | `null` | no | | [maximum\_retry\_attempts](#input\_maximum\_retry\_attempts) | Maximum number of times to retry when the function returns an error. Valid values between 0 and 2. Defaults to 2. | `number` | `null` | no | | [memory\_size](#input\_memory\_size) | Amount of memory in MB your Lambda Function can use at runtime. Valid value between 128 MB to 10,240 MB (10 GB), in 64 MB increments. | `number` | `128` | no | diff --git a/main.tf b/main.tf index 62a1fcab..68c2f9b6 100644 --- a/main.tf +++ b/main.tf @@ -120,8 +120,8 @@ resource "aws_lambda_function" "this" { content { log_group = var.logging_log_group log_format = var.logging_log_format - application_log_level = var.logging_application_log_level - system_log_level = var.logging_system_log_level + application_log_level = var.logging_log_format == "Text" ? null : var.logging_application_log_level + system_log_level = var.logging_log_format == "Text" ? null : var.logging_system_log_level } } diff --git a/variables.tf b/variables.tf index 55816734..c5c10395 100644 --- a/variables.tf +++ b/variables.tf @@ -787,13 +787,13 @@ variable "logging_log_format" { variable "logging_application_log_level" { description = "The application log level of the Lambda Function. Valid values are \"TRACE\", \"DEBUG\", \"INFO\", \"WARN\", \"ERROR\", or \"FATAL\"." type = string - default = null + default = "INFO" } variable "logging_system_log_level" { description = "The system log level of the Lambda Function. Valid values are \"DEBUG\", \"INFO\", or \"WARN\"." type = string - default = null + default = "INFO" } variable "logging_log_group" { diff --git a/wrappers/main.tf b/wrappers/main.tf index 85b9e38c..b719de05 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -75,10 +75,10 @@ module "wrapper" { layers = try(each.value.layers, var.defaults.layers, null) license_info = try(each.value.license_info, var.defaults.license_info, "") local_existing_package = try(each.value.local_existing_package, var.defaults.local_existing_package, null) - logging_application_log_level = try(each.value.logging_application_log_level, var.defaults.logging_application_log_level, null) + logging_application_log_level = try(each.value.logging_application_log_level, var.defaults.logging_application_log_level, "INFO") logging_log_format = try(each.value.logging_log_format, var.defaults.logging_log_format, "Text") logging_log_group = try(each.value.logging_log_group, var.defaults.logging_log_group, null) - logging_system_log_level = try(each.value.logging_system_log_level, var.defaults.logging_system_log_level, null) + logging_system_log_level = try(each.value.logging_system_log_level, var.defaults.logging_system_log_level, "INFO") maximum_event_age_in_seconds = try(each.value.maximum_event_age_in_seconds, var.defaults.maximum_event_age_in_seconds, null) maximum_retry_attempts = try(each.value.maximum_retry_attempts, var.defaults.maximum_retry_attempts, null) memory_size = try(each.value.memory_size, var.defaults.memory_size, 128)