title: AWS PHP SDK Credentials error S
body: <p>I get the following error when trying to create an <code>SNSClient</code> object.</p>
  
  <pre><code>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
  [url] http://169.254.169.254/latest/meta-data/iam/security-credentials/)
  </code></pre>
  
  <p>I don't understand why I have this error when I have my <code>aws.php</code> in the config folder of my laravel setup. Here the access key and secret key are stored.</p>
  
  <p>I don't really like this since this causes my credentials to be stored in the folder setup where other's may SFTP into. </p>
  
  <p>What I also have is the aws credentials and config files in my server root folder, in a path like this: <code>~/.aws/</code> but for some reason the application is not happy.</p>
  
  <p>Here's what my code looks like:</p>
  
  <pre><code>public function about(){
  
      // Instantiate a client with the credentials from the project1 profile
      $snsClient = SnsClient::factory(array(
              'profile' =&gt; 'default',
              'region'  =&gt; 'us-west-2',
          ));
  
      // Get the application's endpoints
  
      $iOS_AppArn = "arn:aws:sns:us-west-2:235418406768:app/APNS_SANDBOX/ClashTarget";
  
      $iOS_model = $snsClient-&gt;listEndpointsByPlatformApplication(array('PlatformApplicationArn' =&gt; $iOS_AppArn));
  }
  </code></pre>
  
  <p>Note that I am using the <code>default</code> profile which should take the credentials from the root aws directory where the config and credential files are stored.</p>
  
  <p>For now, as a temporary solution I did this: <a href="http://blog.ianholden.com/aws-s3-with-php-on-apache/" rel="nofollow">http://blog.ianholden.com/aws-s3-with-php-on-apache/</a> which makes everything work but I'm not happy having my credential keys living in the application code. It doesn't feel right.</p>
  
  <p>Can someone guide me in getting this error resolved please?</p>
  
  <p><strong>Update 1: Comment: What is the content of config at ~/.aws/</strong>
  This is the content of the config file in the <code>~/.aws/</code> folder</p>
  
  <pre><code>[default]
  output = json
  region = us-west-2
  </code></pre>