amazon-web-services - 不允许:no-auth-role/CognitoIdentityCredentials 无权执行:geo:ListGeofences on resource:xxxxx
问题描述
我正在尝试使用 SDK 本身(位置)中的一些新的 Amazon 位置服务端点,但遇到了一些不一致的错误。
即使 IAM 角色中允许的所有内容geo:*
(每个资源都相同),我总是发现诸如locationClient.listGeofences
.
随意,其他一些函数,如getMapStyleDescriptor
,searchPlaceIndexForText
或calculateRoute
不给出问题。这些函数在 中使用它们各自的策略geo:...
,因此看到它如何检测到某些策略而其他策略不让我感到非常困惑。
该错误很常见,它显示以下内容以及已允许的策略:
Uncaught (in promise) AccessDeniedException: User: arn:aws:sts::xxxx:assumed-role/AmazonLocationTestRole/CognitoIdentityCredentials is not authorized to perform: geo:ListGeofences on resource: arn:aws:geo:eu-west-1:xxxx:*
请注意,该访问权限适用于在 Cognito 中具有身份池的未经身份验证的用户,但这不应该是问题。
const client = new AWS.Location({
credentials: credentials,
region: AWS.config.region
});
console.log(await client.listGeofences({
CollectionName: "explore.geofence-collection"
}).promise())
console.log(await client.getMapStyleDescriptor({
MapName: mapName
}).promise());
以防万一,IAM 角色中的信任关系如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "eu-west-1:xxxx"
},
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "unauthenticated"
}
}
}
]
}
并且已经允许针对 Amazon Location Service 中的每个资源的每个策略。
你知道会发生什么吗?
非常感谢!
解决方案
根据https://docs.aws.amazon.com/location/latest/developerguide/authenticating-using-cognito.html#cognito-create-user-pool未经身份验证的身份只能访问以下操作:
- 地理:获取地图*
- 地理:SearchPlaceIndex*
- 地理:BatchUpdateDevicePosition
- 地理:计算路线
推荐阅读
- python - 列表索引超出范围如何修复
- amazon-web-services - Using AWS Lambda Authorizer in API Gateway
- c# - 动态 Linq 包含多个值
- visual-studio-code - 在python中获取ModuleNotFoundError,包存在于虚拟环境中
- r - 如果条件使用 json 来抓取多个链接
- reactjs - 函数在组件更新之前执行
- python - 将数字 ID 转换为不同字母数字代码的算法
- filter - Grok过滤器在调试器中工作但不在logstash中
- javascript - 如何将点击功能添加到动态创建的元素?
- r - 如何合并这两个列表