1

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:

  • I can create file using the python function (f.write).
  • If I run os.system("chmod 777 a.sh"), again I get Read-Only file system.
  • If I use rc = subprocess.call("bash a.sh"), I get No such file or directory: 'bash a.sh'
  • The EFS has access point for user 1000:1000 with 777 permissions.
1
  • 3
    Do you need to specify an absolute path such as touch /mnt/my-mount/hello.txt? Commented Sep 25, 2020 at 15:21

2 Answers 2

2

This could be due to having the Lambda role without proper write permissions. You should attach the proper policy or define your custom one: enter image description here

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

Comments

0

Along with the permission, the issue will be with directory path of Access Point. If you are mounting it in lambda, the root directory path "/" will give permission denied issue. So, make sure you use some other absolute path other than default "/".

Access Point Configuration access point configuration

Lambda Configuration lambda configuration

Comments

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.