asmd ashdkj
asmd ashdkj

Reputation: 133

error "read only file system" when I'm trying to create file using bash script in AWS Lambda function (python)

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:

Upvotes: 1

Views: 2063

Answers (2)

rraj gautam
rraj gautam

Reputation: 395

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

Upvotes: 0

bitconym
bitconym

Reputation: 106

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

Upvotes: 2

Related Questions