New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are you sure you are using the correct region for this bucket? #1410

Closed
m4tthumphrey opened this Issue Oct 26, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@m4tthumphrey

m4tthumphrey commented Oct 26, 2017

Yes.

<?php

require 'vendor/autoload.php';

$sdk = new Aws\Sdk([
    'version' => 'latest',
    'region'  => 'eu-west-1',
    'debug' => true,
    'credentials' => [
        'key'    => 'x',
        'secret' => 'x'
    ]
]);

$s3 = $sdk->createS3();

$result = $s3->getObject([
    'Bucket' => 'my-bucket',
    'Key'    => 'hello.txt',
]);

print_r($result);

PHP Fatal error: Uncaught Aws\S3\Exception\PermanentRedirectException: Encountered a permanent redirect while requesting https://my-bucket.s3.eu-west-1.amazonaws.com/hello.txt. Are you sure you are using the correct region for this bucket? in /vendor/aws/aws-sdk-php/src/S3/PermanentRedirectMiddleware.php:49

Bucket: https://www.dropbox.com/s/mk4w43b86tiy28x/Screenshot%202017-10-26%2013.54.21.png?dl=0

When I click "hello.txt" from the console it shows the (presumable) correct URL of https://s3-eu-west-1.amazonaws.com/my-bucket/hello.txt which when I click it returns the a 401 (which is correct).

First time using AWS so I may have missed something obvious....?

@kstich

This comment has been minimized.

Show comment
Hide comment
@kstich

kstich Oct 26, 2017

Contributor

This Permanent Redirect (HTTP 301) can occur when accessing a bucket name that exists but you do not control. Please make sure that your 'Bucket' field in ->getObject is set to exactly the bucket name you created on S3.

Contributor

kstich commented Oct 26, 2017

This Permanent Redirect (HTTP 301) can occur when accessing a bucket name that exists but you do not control. Please make sure that your 'Bucket' field in ->getObject is set to exactly the bucket name you created on S3.

@m4tthumphrey

This comment has been minimized.

Show comment
Hide comment
@m4tthumphrey

m4tthumphrey Oct 31, 2017

The bucket name is set correctly. What's odd is the fact that the URL is changing.

https://s3-eu-west-1.amazonaws.com/my-bucket/hello.txt is the correct URL but the client is looking for https://my-bucket.s3.eu-west-1.amazonaws.com/hello.txt

m4tthumphrey commented Oct 31, 2017

The bucket name is set correctly. What's odd is the fact that the URL is changing.

https://s3-eu-west-1.amazonaws.com/my-bucket/hello.txt is the correct URL but the client is looking for https://my-bucket.s3.eu-west-1.amazonaws.com/hello.txt

@kstich

This comment has been minimized.

Show comment
Hide comment
@kstich

kstich Oct 31, 2017

Contributor

What URL do you receive if you force path style endpoints?

use_path_style_endpoint: (bool) Set to true to send requests to an S3 path style endpoint by default. Can be enabled or disabled on individual operations by setting '@use_path_style_endpoint' to true or false. Note: you cannot use it together with an accelerate endpoint.

This is intended as an investigatory step, not as a full solution.

Contributor

kstich commented Oct 31, 2017

What URL do you receive if you force path style endpoints?

use_path_style_endpoint: (bool) Set to true to send requests to an S3 path style endpoint by default. Can be enabled or disabled on individual operations by setting '@use_path_style_endpoint' to true or false. Note: you cannot use it together with an accelerate endpoint.

This is intended as an investigatory step, not as a full solution.

@kstich

This comment has been minimized.

Show comment
Hide comment
@kstich

kstich Nov 14, 2017

Contributor

Closing due to lack of reply. Please let us know here if there's any new information.

Contributor

kstich commented Nov 14, 2017

Closing due to lack of reply. Please let us know here if there's any new information.

@kstich kstich closed this Nov 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment