2

I am getting the following error when trying to access my s3 bucket with aws rekognition:

message: 'Unable to get object metadata from S3. Check object key, region and/or access permissions.',

My hunch is it has something to do with the region.

Here is the code:

const config = require('./config.json');
const AWS = require('aws-sdk');
AWS.config.update({region:config.awsRegion});
const rekognition = new AWS.Rekognition();


var params = {
   "CollectionId": config.awsFaceCollection
}

rekognition.createCollection(params, function(err, data) {
  if (err) {
    console.log(err, err.stack);
  }
  else  {
    console.log('Collection created');           // successful response
  }

});

And here is my config file:

{
  "awsRegion":"us-east-1",
  "s3Bucket":"daveyman123",
  "lexVoiceId":"justin",
  "awsFaceCollection":"raspifacecollection6"
}

I have given almost all the permissions to the user I can think of. Also the region for the s3 bucket appears to be in a place that can work with rekognition. What can I do?

David Graff
  • 141
  • 1
  • 4
  • 11
  • Which call is failing with the error message you've indicated? You haven't posted any code that interacts with S3. – jarmod Mar 24 '18 at 16:50
  • @jarmod Rekognition makes the subsequent request to S3 and, unfortunately for the developer but understandable from a security perspective, returns a fairly vague message when it can't fetch the referenced object. – Michael - sqlbot Mar 24 '18 at 19:32
  • 1
    @DavidGraff let's clarify -- you are invoking Rekognition in us-east-1. Is that where the bucket Is, also? The bucket needs to be in the same region as the Rekognition endpoint (as opposed to, say, merely being in any of the regions that offer Rekognition). If this is the case, take a look at your bucket logs to see the accesses being attempted by Rekognition, which may give you some kind of lead to follow. – Michael - sqlbot Mar 24 '18 at 19:37
  • 1
    Thanks guys for the replies. It turns out my issue was I wasnt putting a photo in the s3 bucket that matched the one I was uploading. Both my s3 and rekognition are in the same region. – David Graff Mar 24 '18 at 21:23

2 Answers2

4

Was having the same issue and the solution was to to use the same region for the Rekognition API and S3 bucket, and if using a Role make sure that it has proper permissions to access both S3 and Rekognition.

Miguel Mota
  • 20,135
  • 5
  • 45
  • 64
-1

I had the same problem, resolved by choosing the specific aws recommended region for rekognition.