我怎样才能把AssumeRole和boto3一起使用?

2024-09-19 23:27:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试为boto3执行Assume\u角色,但我遇到了下一个错误:

Traceback (most recent call last):
  File "ststest.py", line 7, in <module>
    DurationSeconds=990
  File "/Users/Randal/Desktop/TFG/Venv27/lib/python2.7/site-packages/botocore/client.py", line 269, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/Randal/Desktop/TFG/Venv27/lib/python2.7/site-packages/botocore/client.py", line 323, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the AssumeRole operation: Not authorized to perform sts:AssumeRole

我正在使用python的下一个代码:

^{pr2}$

我的凭证具有用户“Barney”的API和密钥,并且这个属于用户具有以下权限:

-管理员访问:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "*",
      "Resource": "*"
    }
  ]
}

-创建策略:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "arn:aws:iam::533680604961:role/AdminAccess"
        }
    ]
}

有人能帮我吗?在


Tags: inpyapiliblinecalloperationusers