AWS Lambda Python 3.8 runtime says it can execute 32bit libraries. I have a 32 bit executable which was built in C. When I execute the following code - I get:
wrong ELF class: ELFCLASS32
I tried the same on Amazon Linux 2 docker image. The error I get is same. possibly python gives CDLL a 64 bit instance.
Using the 32 bit docker image from ubuntu 32bit/ubuntu:16.04
it works fine.
import platform
print(platform.architecture())
I will have to invoke Python in 32 bit architecture.
C Code:
#include <stdio.h>
int foo() {
printf("Hello, world!\n");
return 0;
}
Python Code:
import ctypes
def lambda_handler(event, context):
libhi = ctypes.CDLL("my32bitlib.so")
libhi.foo()
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
lambda_handler(None, None)