4

When calling AnalyzeDocument I receive an Amazon.Textract.Model.AccessDeniedException:

Additional information: User: arn:aws:iam::[number]:user/service is not authorized to perform: textract:AnalyzeDocument

The user is in a group with the AmazonTextractFullAccess policy being attached (arn:aws:iam::aws:policy/AmazonTextractFullAccess):

group membership

(The user's ARN matches the one from my exception, it's just redacted for privacy reasons).

I use the AWS SDK for .NET. Here's the relevant code:

var region = RegionEndpoint.USEast1;
string bucketName = "my bucket's id";

IAmazonS3 s3Client = new AmazonS3Client(region);
GetObjectResponse getObjRespone = s3Client.GetObject(bucketName, "inv.jpg");
using (var ms = new MemoryStream())
{
    getObjRespone.ResponseStream.CopyTo(ms);
    var textract = new AmazonTextractClient(region);
    var request = new AnalyzeDocumentRequest();
    var document = new Document();
    document.Bytes = ms;
    request.Document = document;
    AnalyzeDocumentResponse response = textract.AnalyzeDocument(request);
}

What am I missing here?

Edit:

Tried the same with the CLI - this one works. I configured it to use the same user.

./aws textract \
    analyze-document \
    --document '{"S3Object":{"Bucket":"my bucket id","Name":"inv.jpg"}}' \
    --feature-types '["TABLES","FORMS"]'
Wolfgang Radl
  • 2,319
  • 2
  • 17
  • 22

0 Answers0