5

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!

1 Answer 1

0

I've encountered similar problems to yours. Did you build your layers from the resource pulled from somewhere like git repository? I pushed my packages to the github with ignoring .so file setting in .gitingore, which caused _rust.abi3.so got lost. And then when my teammate pulled the resource from github and built layers,and deploy it to the aws, the similar error occured.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.