Tag Archives: AWS

Amazon AWS SDK Passing Credentials

As per the the sample codes the AWS API access key and secret is to be stored in the a file called credentials under a folder named .aws 

The location of that .aws folder can be set in the code through this config statement

putenv('HOME=/path/that/you/want/to/set');

But I am more comfortable in passing the credentials through my code so that I can make things more flexible and need not worry about write permissions.

To pass the credentials through code the first thing needed is to remove or not to use the config statement

'profile' => 'default'

The credentials can then be passed like below

$xxxxxxClient = new xxxxxxClient([
   'version' => "<CLIENT VERSION>", /* can be set to 'latest' */
   'region' => "<REGION>",
   'credentials' => array(
     'key' => "<API USER>",
     'secret' => "<API PASS>"
    )
]);

 

Installing Amazon SDK on ISPConfig systems

  1. First install Composer and PHP for the jailed user. This article has the steps
  2. composer require aws/aws-sdk-php  — as the jailed user
  3. There might be an error –
    fopen(/usr/share/php/Composer/Autoload/../../../doc/composer/copyright): failed to open stream: No such file or directory
  4. You can copy the file using the root login
    1. mkdir -p /var/www/clients/client1/web1/usr/share/doc/composer
    2. cp /usr/share/doc/composer/copyright  /var/www/clients/client1/web1/usr/share/doc/composer/
    3. chown web1:client1 /var/www/clients/client1/web1/usr/share/doc/composer/copyright