Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
AWS S3: confusion on bucket region and identityPoolId (Swift)

I'm having trouble downloading a file from my AWS S3 bucket (Swift/iOS app). It seems to be one of two problems, but I can't tell which:

  1. Problem with my identityPoolId
  2. Problem with the region for the bucket

If I create the credentialsProvider like this:

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];

I get the following error:

[Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=10 "(null)" UserInfo={__type=ResourceNotFoundException, message=Identity 'us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found.}]

I noticed the mismatch on the line where I create the credentials provider: the regionType is AWSRegionUSEast1, but I have "us-west-2" as part of the identityPoolId.

If I change the regionType to AWSRegionUSWest2 (to match my id), the ResourceNotFoundExeception goes away. But then I get this:

<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><Bucket>sportsmanregs</Bucket><Endpoint>s3.amazonaws.com</Endpoint><RequestId>AEFD833FF4E7B6F1</RequestId><HostId>mYxbBKlzTeWgVZW4W060+ESiBhWuxmfDDFE6UriXG7bqxA5NWuRbH9lu4NuGCaU/7H8f1hjAukA=</HostId></Error>

What is interesting is the above error is found in the data object in the completion handler, as in "data" in the following:

completionHandler = {
        (task, location, data, error) -> Void in DispatchQueue.main.async( execute: {

So the completionHandler gets called OK. In the S3 console, the url to the file I am trying to download starts with "https://s3.amazonaws.com//xxx/xxx.tiff". Does anyone have an idea as to what the problem is here?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

It sounds like both your identity pool and your S3 bucket are in the us-west-2 region. You addressed the identity pool part on yourself, and that is correct. In order to fix the bucket region on your code, you need to pass the region to the S3 call too, otherwise it will use the default of us-east-1 and give you that error.

An alternative would be to specify your url with [bucketname].s3.amazonaws.com, some people seemed to have success with that, but it will probably by just fixing the region.

over 4 years ago · Santiago Trujillo Report

0

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"us-west-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"];

It is correct but you need to add some line of code. Please add this code:

 NSString *cognitoId = credentialsProvider.identityId;
    NSString *cognitopoolId = credentialsProvider.identityPoolId;
    NSLog(@"This is cognitoId: %@",cognitoId);
    NSLog(@"This is cognitopoolId: %@",cognitopoolId);

    [[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task){

        if (task.error == nil) {
            NSString* cognitoId = credentialsProvider.identityId;
            NSLog(@"cognitoId: %@", cognitoId);
        } else {
            NSLog(@"Error : %@", task.error);
        }
        return nil;
    }];
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!