Category Archives: aws-php-sdk

AWS PHP SDK Credentials error S

I get the following error when trying to create an SNSClient object.

InstanceProfileCredentialsException in InstanceMetadataClient.php line 85: Error retrieving credentials from the instance profile metadata server. When you are not running inside of Amazon EC2, you must provide your AWS access key ID and secret access key in the "key" and "secret" options when creating a client or provide an instantiated Aws\Common\Credentials\CredentialsInterface object. (Client error response
[status code] 404
[reason phrase] Not Found

I don't understand why I have this error when I have my aws.php in the config folder of my laravel setup. Here the access key and secret key are stored.

I don't really like this since this causes my credentials to be stored in the folder setup where other's may SFTP into.

What I also have is the aws credentials and config files in my server root folder, in a path like this: ~/.aws/ but for some reason the application is not happy.

Here's what my code looks like:

public function about(){

    // Instantiate a client with the credentials from the project1 profile
    $snsClient = SnsClient::factory(array(
            'profile' => 'default',
            'region'  => 'us-west-2',

    // Get the application's endpoints

    $iOS_AppArn = "arn:aws:sns:us-west-2:235418406768:app/APNS_SANDBOX/ClashTarget";

    $iOS_model = $snsClient->listEndpointsByPlatformApplication(array('PlatformApplicationArn' => $iOS_AppArn));

Note that I am using the default profile which should take the credentials from the root aws directory where the config and credential files are stored.

For now, as a temporary solution I did this: which makes everything work but I'm not happy having my credential keys living in the application code. It doesn't feel right.

Can someone guide me in getting this error resolved please?

Update 1: Comment: What is the content of config at ~/.aws/ This is the content of the config file in the ~/.aws/ folder

output = json
region = us-west-2