生成临时令牌以通过浏览器将文件上传到s3存储桶

时间:2019-12-04 14:38:11

标签: python amazon-web-services amazon-s3 boto3 amazon-iam

我需要通过浏览器(使用React Js)将访问数据传递到s3存储桶以执行文件上传操作。以here为例实现。我的任务是将访问数据从后端(python)传输到前端。为此,我假设使用boto3并调用 get_session_token 方法。

import json
import boto3 


client = boto3.client('sts')
token = client.get_session_token()

response = {
    "token": token
     }


def lambda_handler(event, context):

    return {
        'statusCode': 200,
        'body': json.dumps(response)
    }

但是我遇到了一个错误An error occurred (AccessDenied) when calling the GetSessionToken operation: Cannot call GetSessionToken with session credentials

我的lambda角色策略包括AdministratorAccess。 我想念什么?我选择了正确的方法吗?

0 个答案:

没有答案