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

查看:627
本文介绍了无法从/.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 Aws\Route53\Route53Client;

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

出现此错误:

Fatal error: Uncaught Aws\Exception\CredentialsException: Cannot read credentials from /.aws/credentials

似乎容易修复的方法是确保HOME目录是正确的目录.确实已经是.文件可读,我的ec2-user已经是所有者. 密钥和机密"已安装在凭据"文件中.配置文件名称已设置为默认".试图将/.aws复制到其他目录(例如根目录,/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'),

我到底在做错什么?

推荐答案

不确定您在做什么,但我建议完全绕过该问题,并为有问题的vm分配一个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天全站免登陆