Skip to content

Commit

Permalink
feat: add logging_config
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLicense committed Jan 12, 2024
1 parent be31ada commit 8c95305
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ No modules.
| <a name="input_layers"></a> [layers](#input\_layers) | List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. | `list(string)` | `null` | no |
| <a name="input_license_info"></a> [license\_info](#input\_license\_info) | License info for your Lambda Layer. Eg, MIT or full url of a license. | `string` | `""` | no |
| <a name="input_local_existing_package"></a> [local\_existing\_package](#input\_local\_existing\_package) | The absolute path to an existing zip-file to use | `string` | `null` | no |
| <a name="input_logging_config_application_log_level"></a> [logging\_config\_application\_log\_level](#input\_logging\_config\_application\_log\_level) | The application log level of the Lambda Function. Valid values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", or "FATAL". | `string` | `null` | no |
| <a name="input_logging_config_log_format"></a> [logging\_config\_log\_format](#input\_logging\_config\_log\_format) | The log format of the Lambda Function. Valid values are "JSON" or "Text". | `string` | `null` | no |
| <a name="input_logging_config_log_group"></a> [logging\_config\_log\_group](#input\_logging\_config\_log\_group) | The CloudWatch log group to send logs to. | `string` | `null` | no |
| <a name="input_logging_config_system_log_level"></a> [logging\_config\_system\_log\_level](#input\_logging\_config\_system\_log\_level) | The system log level of the Lambda Function. Valid values are "DEBUG", "INFO", or "WARN". | `string` | `null` | no |
| <a name="input_maximum_event_age_in_seconds"></a> [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 |
| <a name="input_maximum_retry_attempts"></a> [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 |
| <a name="input_memory_size"></a> [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 |
Expand Down
2 changes: 2 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module "lambda_function" {
architectures = ["x86_64"]
publish = true

logging_config_log_format = "JSON"

source_path = "${path.module}/../fixtures/python3.8-app1"

store_on_s3 = true
Expand Down
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ resource "aws_lambda_function" "this" {
}
}

dynamic "logging_config" {
for_each = var.logging_config_log_format != null ? [true] : []
content {
log_format = var.logging_config_log_format
application_log_level = var.logging_config_application_log_level
system_log_level = var.logging_config_system_log_level
log_group = var.logging_config_log_group
}
}

timeouts {
create = try(var.timeouts.create, null)
update = try(var.timeouts.update, null)
Expand Down
28 changes: 28 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -761,3 +761,31 @@ variable "recreate_missing_package" {
type = bool
default = true
}

############################################
# Lambda Advanced Logging Settings
############################################

variable "logging_config_log_format" {
description = "The log format of the Lambda Function. Valid values are \"JSON\" or \"Text\"."
type = string
default = null
}

variable "logging_config_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
}

variable "logging_config_system_log_level" {
description = "The system log level of the Lambda Function. Valid values are \"DEBUG\", \"INFO\", or \"WARN\"."
type = string
default = null
}

variable "logging_config_log_group" {
description = "The CloudWatch log group to send logs to."
type = string
default = null
}
4 changes: 4 additions & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +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_config_application_log_level = try(each.value.logging_config_application_log_level, var.defaults.logging_config_application_log_level, null)
logging_config_log_format = try(each.value.logging_config_log_format, var.defaults.logging_config_log_format, null)
logging_config_log_group = try(each.value.logging_config_log_group, var.defaults.logging_config_log_group, null)
logging_config_system_log_level = try(each.value.logging_config_system_log_level, var.defaults.logging_config_system_log_level, null)
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)
Expand Down

0 comments on commit 8c95305

Please sign in to comment.