AWS SE create bucket returns error statust code 400 IllegalLocationConstraintException

0

status code 400 IllegalLocationConstraintException The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

Using SDK PHP I am setting the LocationConstraint for

      $response = $s3Client->createBucket(['Bucket' => $bucket_name,
                                           'CreateBucketConfiguration' => [
                                                'LocationConstraint' => 'eu-west-2']
                                         ]);

My account is setup for eu-west-2. I am able to retrieve from an existing bucket setup through the console using this location.

The more I look at the logs it appears to me that while my code appears to be setting the LocationConstration I do not believe it is being sent in the request. However I cannot figure out what I am doing wrong

demandé il y a un an288 vues
2 réponses
0

You must first verify if the AWS S3 bucket name you've assigned through the PHP code isn't already in use.

Try creating the AWS S3 bucket in the AWS Console with that name to confirm.

AWS
vtjean
répondu il y a un an
  • The same error message returns whether or not the bucket exists. Everything I see suggests this error is a result of LocationConstraint not being correct. However I have sent it in the HTTP request as seen above.

    The errors when the bucket exist are

    [reason] => The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again. [class] => BucketAlreadyExistsException

0

Hi

Could you verify the region specified when creating the client? If the specified region on the client is different than what is LocationConstraint we can face this error.

If there is no region defined in the client add the same region as the LocationConstraint and try.

$s3Client = new S3Client([
        'profile' => 'default',
        'region' => 'eu-west-2',
        'version' => '2006-03-01'
    ]);
profile picture
Bisina
répondu il y a un an
  • Yes I have verified the client is eu-west-2 in the client. Indeed my original code did not include locationConstraint in the request I added it after checking documentation. I really wonder if something is wrong with how I am setting it

    My client code is

       $options = array(
            'credentials' => array(
                'key'    => AWS_KEY,
                'secret' => AWS_SECRET,
            ),
            'signature' => 'v4',
            'region' => 'eu-west-2'
        );
    
        // Instantiate the S3 client with your AWS credentials
        return S3Client::factory($options);
    

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions