简体   繁体   中英

Amazon ec2 not instantiate with php

I am working on amazon ec2. When i integrated the code giving following error

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 1996 milliseconds

Here is my code

require __DIR__ . '/aws.phar';

$client = Aws\S3\S3Client::factory([
'key'    => '[********]',
'secret' => '[************]',
'region' => '[us-east-1]', // (e.g., us-east-1)
'version' => 'latest'
]);

echo $client->listBuckets();

Key and Secret shouldn't include [ and ] . Can you try:

'key'    => '********',
'secret' => '************',
'region' => 'us-east-1',

Passing credentials into a client factory method

// Instantiate the S3 client with your AWS credentials
$s3Client = S3Client::factory(array(
    'credentials' => array(
        'key'    => 'YOUR_AWS_ACCESS_KEY_ID',
        'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
    )
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM