Beginner Problems Using the AWS SDK for PHP

This Article covers some of the common problems a beginner might run into when using the AWS SDK for the first time.

1376 views

Edited: 2017-04-11 08:04

The AWS SDK for PHP should be somewhat easy to use, once you have figured out the composer stuff. This article covers some of the errors we encountered when using the AWS S3 for the first time.

Hopefully it will be helpful for someone else who is learning to use the SDK.

PermanentRedirectThe bucket you are attempting to access....

This can happen if you haven't specified a Region in your factory method, otherwhise you may get strange errors from the AWS. I.e.

PermanentRedirectThe bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

You can set your region using the factory method of the SDK. I.e.

$client = S3Client::factory(array(
    'key'    => '',
    'secret' => '',
    'region' => 'eu-west-1',
));

Note. According to the documentation, the region looks like: us-east-1, us-west-1, us-west-2, eu-west-1, and so on. You should use whatever correspond to your own region.

SignatureDoesNotMatch, Status Code: 403....

You may encounter this problem if your credentials does not match those provided. I.e.

The request signature we calculated does not match the signature you provided. Check your key and signing method.

Make sure you entered the correct key and secret and try again. The error you are getting might look like the below:

Fatal error: Uncaught Aws\S3\Exception\SignatureDoesNotMatchException: AWS Error Code: SignatureDoesNotMatch, Status Code: 403, AWS Request ID

Tell us what you think:

  1. In this article I will explain how to enable a swapfile on small instances, and why it might be useful, even if you do have enough physical memory.
  2. With some network configurations, TLS/SSL might break when relaunching an EC2 instance from an AMI backup.
  3. How to configure a SMTP server with letsencrypt on an amazon EC2 instance.
  4. How to have multiple public IPs with one AWS EC2 Instance
  5. If you suddenly can not connect to your server in the cloud for no apparent reason, it may be because it is running out of physical memory. In this article, I will discuss a few solutions to this problem.

More in: AWS