问题描述
我在Python中使用boto3
。尽管控制台中已经有两个检测器,但我从AWS Fraud Detector得到了一个空列表。如何修复代码以返回控制台中列出的两个检测器?
代码:
import boto3
fraudDetector = boto3.client('frauddetector',aws_access_key_id='key from the console user',aws_secret_access_key='key from the console user')
response = fraudDetector.get_detectors()
print(response)
输出:
{'detectors': [],'ResponseMetadata': {'RequestId': '7ee05de5-6e73-4fe1-a73f-e36a9a4e5c42','HTTPStatusCode': 200,'HTTPHeaders': {'content-type': 'application/x-amz-json-1.1','date': 'Wed,19 Aug 2020 23:35:07 GMT','x-amzn-requestid': '7ee05de5-6e73-4fe1-a73f-e36a9a4e5c42','content-length': '16','connection': 'keep-alive'},'RetryAttempts': 0}}
我猜这是由于某些IAM /权限问题引起的。我确实验证了凭据在控制台与代码上是否匹配。但是,该帐户也是root用户。
解决方法
基于评论。
问题是boto3在控制台使用的不同区域中搜索检测器。
解决方案是为boto3设置适当的区域。