Skip to content

fix: wrap LOG_LEVEL env var with upper() for Powertools v2 compatibility - #5238

Merged
Brend-Smits merged 1 commit into
mainfrom
fix/uppercase-log-statements
Aug 4, 2026
Merged

Brend-Smits merged 1 commit into
mainfrom
fix/uppercase-log-statements

Conversation

@Brend-Smits

Copy link
Copy Markdown
Contributor

Description

Powertools v2 Logger reads the LOG_LEVEL environment variable without calling .toUpperCase(), and the internal LogLevelThreshold map only has uppercase keys (DEBUG, INFO, WARN, ERROR). When a lowercase value like debug is passed, it fails validation silently and defaults to INFO.

This wraps all LOG_LEVEL assignments with Terraform's upper() function, ensuring the Lambda always receives an uppercase value regardless of how the Terraform variable is cased.

Files changed (9):

  • modules/runners/scale-up.tf
  • modules/runners/scale-down.tf
  • modules/runners/ssm-housekeeper.tf
  • modules/runners/pool/main.tf
  • modules/webhook/eventbridge/webhook.tf
  • modules/webhook/eventbridge/dispatcher.tf
  • modules/webhook/direct/webhook.tf
  • modules/ami-housekeeper/main.tf
  • modules/runner-binaries-syncer/runner-binaries-syncer.tf

Test Plan

  • Deployed to a staging environment with log_level = "debug" and verified Lambdas receive LOG_LEVEL=DEBUG
  • Confirmed debug-level log output appears in CloudWatch after the fix (previously defaulted to INFO silently)
  • Ran terraform validate successfully

Related Issues

N/A — discovered during debugging of silent log level failures after upgrading to @aws-lambda-powertools/logger v2.31.0

Powertools v2 Logger reads LOG_LEVEL without calling .toUpperCase(),
and the LogLevelThreshold map only has uppercase keys. Lowercase values
like 'debug' fail validation silently, defaulting to INFO.

Wrapping with upper() ensures the Lambda always receives uppercase
regardless of the Terraform variable casing.

Signed-off-by: Brend Smits <[email protected]>
@Brend-Smits
Brend-Smits requested a review from a team as a code owner August 4, 2026 07:00
Copilot AI lite review requested due to automatic review settings August 4, 2026 07:00
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates multiple Lambda module definitions so the LOG_LEVEL environment variable is always passed in uppercase, aligning with AWS Lambda Powertools Logger v2’s expected log level keys and preventing silent fallback to INFO.

Changes:

  • Wrap LOG_LEVEL assignments with Terraform upper() across runner, webhook, and housekeeper Lambdas.
  • Standardize log level env-var casing for Powertools v2 compatibility across module entry points.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
modules/runners/scale-up.tf Uppercases LOG_LEVEL for the scale-up Lambda environment.
modules/runners/scale-down.tf Uppercases LOG_LEVEL for the scale-down Lambda environment.
modules/runners/ssm-housekeeper.tf Uppercases LOG_LEVEL for the SSM housekeeper Lambda environment.
modules/runners/pool/main.tf Uppercases LOG_LEVEL for the pool Lambda environment.
modules/webhook/eventbridge/webhook.tf Uppercases LOG_LEVEL for the EventBridge webhook Lambda environment.
modules/webhook/eventbridge/dispatcher.tf Uppercases LOG_LEVEL for the dispatcher Lambda environment.
modules/webhook/direct/webhook.tf Uppercases LOG_LEVEL for the direct webhook Lambda environment.
modules/ami-housekeeper/main.tf Uppercases LOG_LEVEL for the AMI housekeeper Lambda environment.
modules/runner-binaries-syncer/runner-binaries-syncer.tf Uppercases LOG_LEVEL for the runner-binaries syncer Lambda environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/webhook/eventbridge/webhook.tf Resolved
Comment thread modules/webhook/direct/webhook.tf Resolved
Comment thread modules/runners/pool/main.tf Resolved
@Brend-Smits
Brend-Smits merged commit 2394f84 into main Aug 4, 2026
46 checks passed
@Brend-Smits
Brend-Smits deleted the fix/uppercase-log-statements branch August 4, 2026 08:02
edersonbrilhante pushed a commit that referenced this pull request Aug 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.10.2](v7.10.1...v7.10.2)
(2026-08-10)


### Bug Fixes

* **lambda:** bump postcss from 8.5.22 to 8.5.24 in /lambdas
([#5241](#5241))
([17cd322](17cd322))
* **termination-watcher:** only emit SpotInterruptionWarning metric for
actual spot interruption events
([#5245](#5245))
([7480fd5](7480fd5))
* wrap LOG_LEVEL env var with upper() for Powertools v2 compatibility
([#5238](#5238))
([2394f84](2394f84))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
zxkane added a commit to zxkane/terraform-aws-github-runner that referenced this pull request Oct 9, 2026
PR github-aws-runners#5238 wrapped every LOG_LEVEL assignment with upper() so that Powertools
v2 stops silently discarding the value, but it missed
modules/lambda/main.tf. That module builds the environment for four
functions: runners/job-retry, termination-watcher/deregister-retry,
termination-watcher/notification and termination-watcher/termination.

The variable is validated against lowercase names only ("debug", "info",
"warn", "error"), so the value reaching those four functions can never
match Powertools' uppercase LogLevelThreshold keys. Every level silently
resolves to INFO. Requesting "debug" yields no debug output, and
requesting "warn" or "error" yields more output than asked for.

POWERTOOLS_LOGGER_LOG_EVENT keeps comparing the raw lowercase variable,
which is still correct.
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 this pull request may close these issues.

3 participants