diff --git a/README.md b/README.md index 5ee449f..5458ed5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Doing serverless with Terraform? Check out [serverless.tf framework](https://ser ## Supported Features -- AWS Lambda runtime Python 3.11 +- AWS Lambda runtime Python 3.13 - Create new SNS topic or use existing one - Support plaintext and encrypted version of Slack webhook URL - Most of Slack message options are customizable @@ -23,7 +23,7 @@ Doing serverless with Terraform? Check out [serverless.tf framework](https://ser ```hcl module "notify_slack" { source = "terraform-aws-modules/notify-slack/aws" - version = "~> 5.0" + version = "~> 7.0" sns_topic_name = "slack-topic" @@ -122,6 +122,7 @@ See the [functions](https://github.com/terraform-aws-modules/terraform-aws-notif | [lambda\_role](#input\_lambda\_role) | IAM role attached to the Lambda Function. If this is set then a role will not be created for you. | `string` | `""` | no | | [lambda\_source\_path](#input\_lambda\_source\_path) | The source path of the custom Lambda function | `string` | `null` | no | | [log\_events](#input\_log\_events) | Boolean flag to enabled/disable logging of incoming events | `bool` | `false` | no | +| [log\_level](#input\_log\_level) | Logging level for the Lambda function | `string` | `"INFO"` | no | | [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no | | [recreate\_missing\_package](#input\_recreate\_missing\_package) | Whether to recreate missing Lambda package if it is missing locally or not | `bool` | `true` | no | | [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations | `number` | `-1` | no | diff --git a/functions/notify_slack.py b/functions/notify_slack.py index b68e054..61595d6 100644 --- a/functions/notify_slack.py +++ b/functions/notify_slack.py @@ -23,6 +23,10 @@ # Set default region if not provided REGION = os.environ.get("AWS_REGION", "us-east-1") +# Initialize logging +logger = logging.getLogger() +logger.setLevel(os.environ.get("LOG_LEVEL", "INFO")) + # Create client so its cached/frozen between invocations KMS_CLIENT = boto3.client("kms", region_name=REGION) diff --git a/main.tf b/main.tf index 7e2fdf2..72f8d5d 100644 --- a/main.tf +++ b/main.tf @@ -117,6 +117,7 @@ module "lambda" { SLACK_USERNAME = var.slack_username SLACK_EMOJI = var.slack_emoji LOG_EVENTS = var.log_events ? "True" : "False" + LOG_LEVEL = var.log_level } create_role = var.lambda_role == "" diff --git a/variables.tf b/variables.tf index 7b958e5..3aa053c 100644 --- a/variables.tf +++ b/variables.tf @@ -168,6 +168,12 @@ variable "log_events" { default = false } +variable "log_level" { + description = "Logging level for the Lambda function" + type = string + default = "INFO" +} + variable "reserved_concurrent_executions" { description = "The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations" type = number