Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda