I have python (3.8) Lambda function that connected to EFS, in mount /mnt/my-mount
.
I want to run a bash script via the function, so I created another file script.sh
.
This is the python function:
import json
import os
def lambda_handler(event, context):
os.system("sh script.sh")
and bash script script.sh
:
#!/bin/bash
touch hello.txt
and I get the following error:
cannot touch script.sh: Read-only file system
Notes:
os.system("chmod 777 a.sh")
, again I get Read-Only file system
.rc = subprocess.call("bash a.sh")
, I get No such file or directory: 'bash a.sh'
1000:1000
with 777
permissions.This could be due to having the Lambda role without proper write permissions. You should attach the proper policy or define your custom one: