无法从/.aws/credentials 读取凭证 - PHP 脚本调用 AWS-SDK [英] Cannot read credentials from /.aws/credentials - PHP script call AWS-SDK

查看:46
本文介绍了无法从/.aws/credentials 读取凭证 - PHP 脚本调用 AWS-SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经查看了这里的每个答案,似乎我的问题有点不同,或者没有合适的解决方案.我在我的 PHP 文件中执行以下操作:

I've looked at every answer on here and it seems my problem is a little different or there hasn't been a proper solution. I'm doing the following in my PHP file:

use AwsRoute53Route53Client;

$client = Route53Client::factory(array(
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2013-04-01'
));

出现此错误:

Fatal error: Uncaught AwsExceptionCredentialsException: Cannot read credentials from /.aws/credentials

似乎简单的解决方法是确保 HOME 目录是正确的.确实已经是了.文件可读并且我的 ec2-user 已经是所有者.密钥和秘密已安装在凭据"文件中.配置文件名称已设置为默认".尝试将/.aws 复制到其他目录,例如 root、/home 等,并更改权限、chmod、以上所有内容.还是什么都没有.

Seems like the easy fix would be ensure that the HOME directory is the right one. Indeed it already is. Files are readable and my ec2-user is already the owner. Key and Secret is already installed in the 'credentials' file. Profile name is already set to 'default.' Tried to copy /.aws to other directories such as the root, /home, etc and changed permissions, chmod, all the above. Still nothing.

然后我尝试对凭据进行硬编码(我知道 - 不推荐)只是为了给它一点刺激,它完全忽略了我这样做了:

Then I tried to hard-code the credentials (I know -- not recommended) just to give it a little kick, and it completely ignores that I did this:

$client = Route53Client::factory(array(
    'profile' => 'default',
    'region' => 'us-east-1',
    'version' => '2013-04-01',
    'credentials' => [
            'key' => $key,
            'secret' => $secret,
    ]
));

作为最后的手段,我什至尝试包含 CredentialProvider 类,并将其传递到我的数组中 - 仍然没有:

As a last resort, I even tried including the CredentialProvider class, and passing this into my array -- still nothing:

'credentials' => CredentialProvider::ini('default', '/home/ec2-user/.aws/credentials'),

我到底做错了什么?

推荐答案

不确定您做错了什么,但我建议您完全绕过该问题并将 EC2 实例角色分配给有问题的虚拟机,然后您就不会了'不必担心;这是一个更好/更安全的解决方案.

Not sure what you are doing wrong, but I'd suggest bypassing the problem altogether and assigning an EC2 Instance role to the vm in question and then you won't have to worry about it; it's a better/more secure solution.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

这篇关于无法从/.aws/credentials 读取凭证 - PHP 脚本调用 AWS-SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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