AWS Lambda函数列出用户的权限

时间:2019-06-05 15:50:10

标签: amazon-web-services aws-lambda amazon-cognito amazon-iam

我有一个AWS Lambda函数,该函数需要能够运行以下代码:

var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();

cognitoidentityserviceprovider.listUsers(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
  .... other useful code ....
});

换句话说,它应该能够 listUsers

为此在IAM中设置角色时,我需要什么样的政策?

2 个答案:

答案 0 :(得分:1)

如果要列出Cognito用户池中的用户,则需要允许cognito-idp:ListUsers。您可以将操作限制为特定的用户池,如下所示:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "cognito-idp:ListUsers",
            "Resource": "arn:aws:cognito-idp:<region>:<account>:userpool/<userpoolid>"
        }
    ]
}

看看Actions, Resources, and Condition Keys for Amazon Cognito User Pools

答案 1 :(得分:0)

您需要授予IAM角色cognito-identity:ListIdentities,以获取更多信息。 https://iam.cloudonaut.io/reference/cognito-identity.html

该列表操作可能存在依赖性。

您也可以 cognito-identity:*,如果您需要限制性较小的策略来进行明智的测试。

相关问题