我已通过 AWS Cloud 9 创建了 Lambda Python 函数,但在尝试从 Lambda 函数写入 S3 存储桶时遇到了问题。当我在 Cloud 9 中测试时,Python 代码运行良好并完美写入 S3 存储桶。当我将其推送到 Lambda 函数并且它运行时,我认为会出现错误。这让我认为 5 月 9 日运行应用程序的角色与 Lambda 函数运行时的角色之间存在不同的权限。
给出了以下错误,我正在寻找一些关于我可能缺少的内容的建议,在错误下方我描述了设置:
[ERROR] ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
Traceback (most recent call last):
File "/var/task/index.py", line 22, in handler
s3.Bucket(bucket_name).put_object(Key=s3_path, Body=encoded_string)
File "/var/runtime/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/var/runtime/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/var/runtime/botocore/client.py", line 320, in _api_call …Run Code Online (Sandbox Code Playgroud)