Closed myz540 closed 1 year ago
Looking into this more closely, I've determined that I can get this to work by specifying the docker_image
as the lambda runtime image instead of the default build image. Setting docker_image = public.ecr.aws/lambda/python:3.9-x86_64
fixes it, but this is still not ideal since it suggests ABI compatibility issues between the lambda runtime and the supported SAM build containers (which are used here)
This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
Hello, why was this issue not addressed and closed? This is still not addressed and the latest python 3.9 runtime update on 6/12/23 has broken it again!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
When trying to create a layer that has
psutil
. The package builds just fine and passes the eye test, but when deployed and included as a dependent layer, the subsequentimport
statement in the lambda function results in anImportError
Versions
Module version [Required]: 4.16.0
Terraform version: Terraform v1.3.2 on darwin_arm64
Provider version(s):
provider registry.terraform.io/hashicorp/archive v2.3.0
provider registry.terraform.io/hashicorp/aws v4.63.0
provider registry.terraform.io/hashicorp/external v2.3.1
provider registry.terraform.io/hashicorp/local v2.4.0
provider registry.terraform.io/hashicorp/null v3.2.1
Reproduction Code [Required]
To reproduce the error, you'll need 3 files, the
lambda.tf
file, therequirements.txt
file, and alambda_function.py
file. Put thelambda_function.py
into a folder calledlambda
to prevent packaging all the terraform modules./terraform file
./requirements.txt
./lambda/lambda_function.py
Now, you can just invoke the lambda function to observe the
ImportError
Expected Behavior
I would expect the module to load and not hit an
ImportError
Actual behavior
Terminal Output Screenshot(s)
Lambda log above
Additional context
This is an issue we are just encountering as we are trying to re-factor our lambda code to use this module. Overall, we like the
module
a lot but this has been a roadblock for us. It's unclear why our current build + packaging has a workingpsutil
import but this configuration does not. Also, we had to addprefix_in_zip = "python"
to get the source paths to import anything at all. In our example, we importyaml
to show that the requirements were installed.Of note, we are able to see the
_psutil_linux.abi3.so
as listed in the location where it is looking but unclear why it isn't being imported