在亚马逊AWS中获得许可被拒绝 [英] getting permission denied in amazon aws

查看:157
本文介绍了在亚马逊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

  1. 我已经在.aws\credentials处创建了credentials.ini文件.它具有有效的AWSAccessKeyIdAWSSecretKey

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

[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:

    1. 首先,PHP库尝试从环境中获取凭据,但是它们不存在,所以...
    2. 接下来,它尝试从INI文件中获取它们,但是您拼错了密钥,所以...
    3. 最后,它尝试从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屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆