【问题标题】:ClientError: (AccessDenied) when calling the sts:AssumeRole operation for the AWS account used to connect Amazon SP-APIClientError: (AccessDenied) 调用用于连接 Amazon SP-API 的 AWS 账户的 sts:AssumeRole 操作时
【发布时间】:2021-09-30 17:22:43
【问题描述】:

我想连接到 Amazon SP-API。它在文档中说我需要创建一个 AWS 账户并添加必要的权限,以便我可以使用它来连接 Amazon SP-API。我们的开发人员资料已获批准,我们已注册我们的应用程序。我尝试使用此 python SP-API library 连接这些凭据。

但是,我有一个错误提示:

botocore.exceptions.ClientError:调用 AssumeRole 操作时发生错误 (AccessDenied):用户:arn:aws:iam:::user/username is not authorized to perform: sts:AssumeRole on resource:arn :aws:iam:::user/username

我认为我的错误原因是我的权限政策。以下关于如何声明的政策有问题吗?

//STS-POLICY
{ 
    "Version": "2012-10-17", 
    "Statement": [
        {
            "Sid":  "VisualEditor0",
            "Effect" : "Allow",
            "Action": "sts:*",
            "Resource": "arn:aws:iam::<account_id>:user/<username>"
        }
    ]
}
//EXECUTE-API-POLICY
{ 
    "Version": "2012-10-17", 
    "Statement": [
        {
            "Sid":  "VisualEditor0",
            "Effect" : "Allow",
            "Action": "execute-api:*",
            "Resource": "arn:aws:execute-api::<account_id>:*/*/*/*"
        }
    ]
}

【问题讨论】:

    标签: amazon-web-services amazon-iam amazon-mws aws-sts


    【解决方案1】:

    当您尝试将 AssumeRole 与 STS-Policy 一起使用时,Rosource 应该是角色而不是用户。

    在 STS-Policy 中更改这一行

    "Resource": "arn:aws:iam::<account_id>:user/<username>"
    

    喜欢这个。

    Resource": "arn:aws:iam::<account_id>:role/<rolename>"
    

    请参阅this aws doc 的“授予担任角色权限的示例策略”部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-08
      • 1970-01-01
      相关资源
      最近更新 更多