[Python] How can I implement R as a layer in an AWS Lambda Python Runtime?

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have been attempting to create a layer containing R CLI and all of its dependencies that I can attach to my AWS Lambda and run through some subprocess commands. I have done something similar with Open Policy Agent, which I would execute as such

    result = subprocess.run(
    ["/opt/bin/opa", "build", "-t", "wasm", "-e", "test/main", local_rego_path, "-o", opa_output_tar],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
    )


    I have tried using ec2 to download, create, and zip the layer, but when I add the layer to my aws lambda function and attempt to invoke it, I get a Runtime.ExitError. Error:Runtime exited with error: exit status 255. I also see a message consistently, "Rscript execution failed with status 255", which I am assuming means it cannot find it.

    I have spent over 20+ hours trying to rebuild, debug, add dependencies and fix this error, but I can't seem to shake it.

    Is this approach even possible, and if so, has it been done before?

    I do have a docker container running python and R working, but I was really hoping I could build a solution in an AWS Lambda Python runtime with R cli, and its dependencies as a layer.

    Continue reading...

Compartilhe esta Página