AWS SDK for PHP: Error retrieving credentials from the instance profile metadata server

后端 未结 9 857
灰色年华
灰色年华 2020-12-04 21:18

I am trying to send SNS messeges to android through web api. Downloaded and installed the SDK from http://aws.amazon.com/developers/getting-started/php/

Got followin

9条回答
  •  天涯浪人
    2020-12-04 22:00

    I was trying to use a credentials file and got the same error, this guy on github pretty much nailed it:

    The credentials file should be in ini format but not have a .ini extension. It should have a 'default' section defined with your key and secret:

    $ less ~/.aws/credentials
    
    [default]
    aws_access_key_id = key
    aws_secret_access_key = secret
    

    If you specified other section name instead of default, just add a profile key to the S3Client parameters:

    [example]
    aws_access_key_id = key
    aws_secret_access_key = secret
    
    $s3Client = new \Aws\S3\S3Client([
        'version' => '2006-03-01',
        'region' => $yourPreferredRegion,
        'profile' => 'example',
    ]);
    

    Using a credentials file or environment variables is the recommended way of providing credentials on your own server

    And @Anti 's answer also helped me alot!

    If you prefer the hard coded way, just follow @shadi 's answer.

提交回复
热议问题