Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The logging in Lambda functions in privatelink-access pattern doesn't work #1798

Closed
vchintal opened this issue Oct 20, 2023 · 0 comments · Fixed by #1800
Closed

The logging in Lambda functions in privatelink-access pattern doesn't work #1798

vchintal opened this issue Oct 20, 2023 · 0 comments · Fixed by #1800

Comments

@vchintal
Copy link
Contributor

vchintal commented Oct 20, 2023

Description

The logging instructions in the files create_eni.py and delete_eni.py do not log any records at INFO or DEBUG log levels.

Versions

  • Module version [Required]:
source  = "terraform-aws-modules/lambda/aws"
version = "~> 5.0"
  • Terraform version:
  • Provider version(s):
Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.22.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.2
+ provider registry.terraform.io/hashicorp/dns v3.3.2
+ provider registry.terraform.io/hashicorp/external v2.3.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.23.0
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/time v0.9.1
+ provider registry.terraform.io/hashicorp/tls v4.0.4

Reproduction Code [Required]

Steps to reproduce the behavior:

  1. Install the pattern using the following commands:
    terraform init
    terraform apply -target=module.eventbridge -target=module.nlb
    terraform apply 
  2. Check the logs for delete_eni Lambda

Expected behaviour

Application logs logged with at least one record at INFO level

Actual behaviour

No application logs logged at all

Additional context

  1. The logger.basicConfig() line has absolutely no affect on the logging.
  2. Based on the documentation this can be attributed to root logger already configured with handlers
  3. One of the ways to enable the logging is to, based on the recommendation in the documentation, change the above line with the one below:
    logging.basicConfig(level=logging.DEBUG, format='%(message)s', force=True)
  4. Though the above step works it logs everything (all API calls in the code) at the DEBUG level and isn't ideal. The ideal way to handle just the application logging is to use logger as shown below:
    # Comment out this line in the code
    # logging.basicConfig(level=logging.DEBUG, format='%(message)s', force=True)
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)
    
    # Replace every logging.info(), logging.debug() and logging.error() with 
    # logger.info(), logger.debug() and logger.error() respectively
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant