Skip to content

Logger isn't properly instantiated and doesn't work #253

@dsiguero

Description

@dsiguero

Description

It looks like the Python code embedded in the Lambda function is using the logging module improperly. Specifically, logging methods like logging.warning(...) and logging.exception(...) are used directly, but no logger is instantiated or configured beforehand.

This results in no logs being emitted to CloudWatch unless another service or library happens to initialize logging correctly first — which is not guaranteed or reliable.

A minimal fix would be to correctly initialize the logger:

import logging
[...]
logger = logging.getLogger()
logger.setLevel(logging.INFO)
[...]
logger.exception("Failed to decrypt URL with KMS")
logger.warning(f"Successfully updated finding status to NOTIFIED: {json.dumps(notified)}")
  • ✋ I have searched the open/closed issues and my issue is not listed.

The issue is listed, but was never actioned, and automatically closed as stale: #192

⚠️ Note

I have reproduced this behavior after clearing .terraform, re-initializing, and applying again.

Versions

  • Module version [Required]: v6.6.0 (latest as of writing)
  • Terraform version: N/A
  • Provider version(s): N/A

Reproduction Code [Required]

Steps to reproduce the behavior:

You can reproduce the issue by deploying the default example from examples/complete and then triggering a notification. Check CloudWatch logs for the Lambda associated with the notify-slack function. Logging calls are made (e.g., logging.warning(...)), but no messages appear in logs.

Expected behavior

Lambda logging output should appear in CloudWatch Logs as expected.

Actual behavior

No logs are emitted. The built-in logging.warning(...) etc. calls don’t work as expected without logger initialization.

I’d be happy to open a PR with the fix if you’re open to contributions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions