Skip to content

Lambda container fails with Runtime.ImportModuleError due to missing src package #85

@oto-macenauer-absa

Description

@oto-macenauer-absa

Describe the bug

Running the Lambda container image built from bugfix/import-error fails immediately with Runtime.ImportModuleError: attempted relative import with no known parent package because the Dockerfile flattens the src directory and the handler imports src.*, so the src package is missing at runtime.

To Reproduce

  1. Build and push the Lambda container image using the existing Dockerfile (copies src/ contents directly into $LAMBDA_TASK_ROOT).
  2. Deploy the image via Terraform with handler event_gate_lambda.lambda_handler.
  3. Invoke the Lambda; CloudWatch logs show Runtime.ImportModuleError: Unable to import module 'event_gate_lambda': attempted relative import with no known parent package.

Expected behavior

The Lambda container should load src.event_gate_lambda.lambda_handler, resolve src.* imports, and execute without an import error.

Screenshots

N/A

Additional context

The fix was to copy src intact into $LAMBDA_TASK_ROOT/src and set both the container CMD and Terraform handler to src.event_gate_lambda.lambda_handler so Python can locate the package structure.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions