Denial permission in amazon aws

I am trying to connect to amazon s3 using an AWS credential file for which I did the following

  • I created the credentials.ini file in .aws\credentials . It has valid AWSAccessKeyId and AWSSecretKey

     [default] AWSAccessKeyId=somekey AWSSecretKey=somesecretkey 
  • I am doing the following to use a key and a list of all objects

.

 $s3 = new Aws\S3\S3Client([ 'version' => 'latest', 'region' => 'us-west-2' ]); $result = $s3->listBuckets(); var_dump($result); 

and i get an error

 Warning: parse_ini_file(C:\Users\user\.aws\credentials): failed to open stream: Permission denied in C:\xampp\htdocs\aws\vendor\aws\aws-sdk-php\src\Credentials\CredentialProvider.php on line 216 Fatal error: Uncaught exception 'Aws\Exception\CredentialsException' with message 'Error retrieving credentials from the instance profile metadata server. (cURL error 28: Connection timed out after 1000 milliseconds (see http://curl.haxx.se/libcurl/c/libcurl-errors.html))' in C:\xampp\htdocs\aws\vendor\aws\aws-sdk-php\src\Credentials\InstanceProfileProvider.php:79 Stack trace: #0 C:\xampp\htdocs\aws\vendor\guzzlehttp\promises\src\Promise.php(199): Aws\Credentials\InstanceProfileProvider->Aws\Credentials\{closure}(Array) #1 C:\xampp\htdocs\aws\vendor\guzzlehttp\promises\src\Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(2, Array, Array) #2 C:\xampp\htdocs\aws\vendor\guzzlehttp\promises\src\TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #3 C:\xampp\htdocs\aws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(96): GuzzleHttp\Promise\TaskQueue->run() #4 C:\xampp\htdocs\aws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(123): GuzzleHttp\Handler\CurlMultiHandler->tick in C:\xampp\htdocs\aws\vendor\aws\aws-sdk-php\src\Credentials\InstanceProfileProvider.php on line 79 
+4
source share
1 answer

According to AWS PHP documentation , the credential file format is as follows:

 [default] aws_access_key_id = YOUR_AWS_ACCESS_KEY_ID aws_secret_access_key = YOUR_AWS_SECRET_ACCESS_KEY 

In your case, here is what I consider:

  • firstly, the PHP library is trying to get credentials from the environment, but they aren’t ...
  • Further, he tries to get them from the INI file, but you wrote the keys incorrectly, so ...
  • finally, he tries to get them from the EC2 metadata server, but it looks like you are not working on an EC2 instance, so there is no metadata server and this attempt using curl is disabled.

This can be seen in the source code for the AWS PHP library .

The end result, which is bubbling up to you, is that step number 3 failed, but actually steps number 1, number 2, and number 3 have failed. So, I think that fixing is as simple as fixing key names in an INI file.

+2
source

All Articles