我正在使用以下代码在本地连接 dynamoDb
$dotenv = new Dotenv\Dotenv(dirname(__DIR__, 2));
$dotenv->load();
$this->key = getenv('aws_access_key_id');
$this->secret = getenv('aws_secret_access_key');
$this->dynamodb = new DynamoDbClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => $this->key,
'secret' => $this->secret,
]
]);
我的.env
档案
aws_access_key_id = ....
aws_secret_access_key = ....
我收到此错误
Type: Aws\Exception\CredentialsException
Message: Cannot read credentials from /Users/user/.aws/credentials
File: /path/to/project/vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php
Line: 394
access key
也尝试了&的基本硬编码,secret key
但它似乎并没有在每次从默认路径获取时都有效~/.aws/credentials
TIA