Reputation: 115
I'm a newbie at aws. I wanted to use the comprehend api with python.
I wrote the following python script:
import boto3
import json
comprehend = boto3.client(service_name='comprehend')
text = "It is raining today in Seattle"
print('Calling DetectSentiment')
sentiment_output=comprehend.detect_sentiment(Text=text, LanguageCode='en')
print('End of DetectSentiment\n')
I created an IAM user with administrator access and configured it in my linux console:
(base) florian@florian3090:~/Desktop/aws$ aws configure
AWS Access Key ID [****************BIP6]:
AWS Secret Access Key [****************a/1f]:
Default region name [us-west-1]:
Default output format [json]:
But there is an error every time I call my python file:
botocore.exceptions.ClientError: An error occurred (NotAuthorizedException) when calling the DetectSentiment operation: Your account is not authorized to make this call.
Unfortunatley I could not solve this error until now.
This is my first AWS project. Do I need to unlock anything? I would really appreciate any tip how to solve this issue.
Thanks in advance!
Upvotes: 0
Views: 473
Reputation: 396
Check whether you're using Comprehend in one of the supported regions (https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/). If you're using it in an unsupported region, it will return that account not authorised error
Upvotes: 0
Reputation: 31
Please ensure that the IAM user/role that you are using has access operation comprehend:DetectSentiment
For example look at IAM policy attached to the user whose credentials you are using . The policy should contain something like this -
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "AllowSentimentDetect",
"Effect": "Allow",
"Action": [
"comprehend:DetectSentiment"
],
"Resource": "*"
}
]
}
Upvotes: 0