0

I'm facing an issue with my AWS Lambda Layer Stack using AWS SAM (Serverless Application Model). I am encountering a Runtime.ImportModuleError with the following error message:

Runtime.ImportModuleError: Unable to import module 'signin': /opt/python/cryptography/hazmat/bindings/_rust.abi3.so: cannot open shared object file: No such file or directory
Traceback (most recent call last): ...

This error is occurring within my AWS Lambda Layer stack. This problem occurred when I migrated the runtime from 3.8 to 3.11. Here's my buildspec.yaml file for reference:

version: 0.2
# Buildspec Reference Doc: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax

# ... (Environment Variables and Phases) ...

phases:
  install:
    runtime-versions:
      python: 3.11
    commands:
      # ... (Install phase commands) ...

  pre_build:
    commands:
      # ... (Pre-Build phase commands) ...
      - cd lambda_layers/global_utils/python
      - pip install -r requirements.txt -t .
      - cd ../../
      - cd ./node
      - npm install
      - mkdir -p ./nodejs
      - mv ./node_modules ./nodejs
      - cd ../../
      - ls

  build:
    commands:
      # ... (Build phase commands) ...
      - echo "Starting SAM packaging `date` in `pwd`"
      - aws cloudformation package --template-file template.yaml --s3-bucket $BUILD_OUTPUT_BUCKET --output-template-file package.yaml

  post_build:
    commands:
      # ... (Post-Build phase commands) ...
      - echo "SAM packaging completed on `date`"

# ... (Artifacts and Cache) ...

I suspect that the error might be related to the some issue with the Python runtime environment in AWS Lambda. Any guidance on how to resolve this issue would be greatly appreciated.

Please note that I've tried different configurations, including changing --platform or --only-binary=:all: flag for the pip install command, but the issue persists. I tried changing the lambda architecture ARM from x86.Problem will may be resolved if I remigrate to python 3.8 but I want to sort it out and switch to 3.11.

Thank you in advance for your assistance!

mubtasimfuad
  • 133
  • 6

0 Answers0