getting permission denied in amazon aws

一个人想着一个人 提交于 2019-12-12 11:32:35

问题


I am trying to connect to amazon s3 by Using the AWS credentials file for that i have done following things

  1. I have created credentials.ini file at .aws\credentials. It have valid AWSAccessKeyId and AWSSecretKey

    [default]
    AWSAccessKeyId=somekey
    AWSSecretKey=somesecretkey
    
  2. I am doing following to use key and list all object

.

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


$result = $s3->listBuckets();
var_dump($result);

and i am getting 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

回答1:


According to the AWS PHP documentation, the format of the credentials file 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 believe is happening:

  1. first, the PHP library tries to get credentials from the environment, but they are not present so ...
  2. next, it tries to get them from the INI file, but you have mis-spelled the keys so ...
  3. finally, it tries to get them from the EC2 metadata server but it looks like you are not running on an EC2 instance so there is no metadata server and that attempt, using curl, times out.

You can see all of this clearly in the source code for the AWS PHP library.

The end result that bubbles up to you is that step #3 failed, but actually steps #1, #2, and #3 failed. So, I think the fix is as simple as correcting the key names in the INI file.



来源:https://stackoverflow.com/questions/31722099/getting-permission-denied-in-amazon-aws

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!