当我尝试在 AWS Lambda 函数 (python) 中使用 bash 脚本创建文件时出现错误 "read only file system"

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

我有 python (3.8) Lambda 函数连接到 EFS,挂载 /mnt/my-mount

我想通过函数 运行 一个 bash 脚本,所以我创建了另一个文件 script.sh.

这是python函数:

import json
import os

def lambda_handler(event, context):
    os.system("sh script.sh")

和bash脚本script.sh:

#!/bin/bash
touch hello.txt

我收到以下错误:

cannot touch script.sh: Read-only file system

备注:

这可能是因为 Lambda 角色没有适当的写入权限。您应该附加适当的政策或定义您的自定义政策: