boto3 not returning elements in the console

Viewed 156

I am using boto3 in Python. I am getting an empty list from AWS Fraud Detector, despite having two detectors already in the console. How can I fix the code to return the two detectors listed in the console?

Console: enter image description here

Code:

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)

Output:

{'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}}

I am guessing that this is due to some IAM / permission issue. I did verify that the credentials match on console vs code. The account is also a root user though.

1 Answers

Based on the comments.

The issue was that boto3 was searching detectors in different region that the region used in console.

The solution was to setup the proper region for boto3.

Related