【发布时间】:2021-09-11 17:45:52
【问题描述】:
我正在尝试使用 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 中每个资源的每个策略都已被允许。
你知道会发生什么吗?
非常感谢!
【问题讨论】:
标签: amazon-web-services aws-sdk amazon-cognito amazon-iam