AWS开发工具包PHP-无法从/.aws/credentials中读取凭证

时间:2018-11-10 18:50:16

标签: php amazon-web-services amazon-s3 aws-sdk

文档或SDK本身似乎有错误。
当没有凭据时,SDK会一直在寻找标准凭据文件。

require('aws/aws-autoloader.php');
use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;
$profile = 'default';
$inipath = '/www/test/.test/credentials.ini';
$provider = CredentialProvider::ini($profile, $inipath);
$provider = CredentialProvider::memoize($provider);

use Aws\Exception\AwsException;
try {

    $s3Client = new S3Client([
            'profile' => 'default',
            'region' => 'eu-central-1',
            'version' => '2006-03-01',
            'credentials' => $provider,
    ]);

由于以下错误而失败:

Uncaught Aws\Exception\CredentialsException: Cannot read credentials from /.aws/credentials in /www/test/aws/Aws/Credentials/CredentialProvider.php:394

有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

我从s3client中删除了'profile'=>'default'并且它起作用了。 似乎配置文件定义了两次。