I am trying to connect to the amazon Rekognition service in region us-east-1. However boto3 always connects to us-west-2.
I have run $ aws configure list
and the credentials and specified region seem to be correct there
I remember when I first filled in the credentials I did not specify a region and it defaulted to us-west-2. Then I edited the file in ~/.aws/config to change the region. It now has the following contents:
[default]
region = us-east-1
However when I run my script
import boto3
bucket='XX'
photo='FOLDER/XX.jpg'
model='arn:aws:rekognition:us-east-1:XX:project/XX/version/XX/XX'
min_confidence=95
client=boto3.client('rekognition', region_name="us-east-1")
response = client.detect_custom_labels(Image={'S3Object':{'Bucket': bucket, 'Name': photo}},
MinConfidence=min_confidence,
ProjectVersionArn=model)
boto3 always connects to us-west-2
And then I get the following error:
An error occurred (InvalidParameterException) when calling the DetectCustomLabels operation: Cross region access not allowed
How can I tell boto3 to connect to a different region?