在亚马逊AWS中获得许可被拒绝 [英] getting permission denied in amazon aws
问题描述
我正在尝试通过使用AWS凭证文件连接到Amazon s3,因为我已经完成了以下操作
I am trying to connect to amazon s3 by Using the AWS credentials file for that i have done following things
-
我已经在
.aws\credentials
处创建了credentials.ini
文件.它具有有效的AWSAccessKeyId
和AWSSecretKey
I have created
credentials.ini
file at.aws\credentials
. It have validAWSAccessKeyId
andAWSSecretKey
[default]
AWSAccessKeyId=somekey
AWSSecretKey=somesecretkey
我正在执行以下操作以使用键并列出所有对象
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);
我遇到错误
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
推荐答案
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:
- 首先,PHP库尝试从环境中获取凭据,但是它们不存在,所以...
- 接下来,它尝试从INI文件中获取它们,但是您拼错了密钥,所以...
- 最后,它尝试从EC2元数据服务器获取它们,但看起来您没有在EC2实例上运行,因此没有元数据服务器,并且使用curl的尝试超时.
您可以在 AWS PHP库的源代码.
冒充您的最终结果是步骤#3失败了,但实际上步骤#1,#2和#3失败了.因此,我认为此修复方法就像更正INI文件中的键名一样简单.
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.
这篇关于在亚马逊AWS中获得许可被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!