从s3桶中获取python类文件并在aws lambda中使用



我需要从s3桶中获取python文件并在我的AWS Lambda中使用它。
例如test.py文件存储在s3桶的某个位置。将使用boto3 get_object()获取py文件的内容。现在需要在lambda中执行py文件吗?

为什么使用这个而不是Lambda图层?更有效和便宜。你只需要从图层中导入。py代码。

无论如何,如果你想这样做,你只需要将get对象命名为result,并将其转换为"text"然后在Lambda函数中调用它。

的例子:

mycode = boto3.get_object(---)
mycode.toString or something like that
def lambda_handler():
mycode (try to exclude the def-lambda_handler in your "mycode" code)

最新更新