python subprocess.call()返回lambda函数中的null响应AWS
我需要运行一个CLI命令,该命令在存储桶内制作文件夹的递归副本,并将ACL设置为“ Buckesl所有者完全控制”。 局部函数正确运行。 但是我需要在AWS控制台中进行测试才能提高生产环境。 在Lambda服务中使用以下代码进行测试时:
import boto3
def lambda_handler(event, context):
subprocess.call(['aws', 's3', 'cp', '--recursive', '--acl', 'bucket-owner-full-control', 's3://bucket1/db1', 's3://bucket1/db1'], shell=True)
我只会得到响应= null ,而我想要的更改不会发生在存储桶内(什么都没发生)。
是否可以在AWS Lambda内运行此子过程模块?
这是AWS控制台中响应的打印:
I need to run a CLI command that makes a recursive copy of folders inside a bucket and sets the ACL as "bucket owner full control".
Locally the function ran correctly.
But I need to test in the AWS console to go up to productive environment.
When testing in lambda service with the following code:
import boto3
def lambda_handler(event, context):
subprocess.call(['aws', 's3', 'cp', '--recursive', '--acl', 'bucket-owner-full-control', 's3://bucket1/db1', 's3://bucket1/db1'], shell=True)
I just get a response = null and the change I want doesn't happen inside the bucket (nothing happens).
Is it possible to run this subprocess module inside AWS Lambda?
This is the print of response in AWS console:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
lambda_handler
不会返回任何内容。您必须向处理程序添加返回语句。但是,即使您这样做也行不通,因为Lambda没有AWS CLI。您应该使用 aws boto3 与您的lambda中的s3互动。
Your
lambda_handler
does not return anything. You have to add return statement to your handler.But even if you do it will not work, as lambda does not have AWS CLI. You should be using AWS boto3 to interact with S3 in your lambda.