• Register
0 votes

Problem :

I am new to AWS. I want to send SNS messages to the android through the web api. I have already downloaded the AWS SDK for PHP also I have already configured my /.aws/credentials file with required AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

Still I am facing below error while running my code :

Fatal error: Uncaught exception 'Aws\Common\Exception\InstanceProfileCredentialsException' with message '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. ([curl] 28: Connection timed out after 5016 milliseconds [url]' in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php:85 Stack trace: #0 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\RefreshableInstanceProfileCredentials.php(52): Aws\Common\InstanceMetadata\InstanceMetadataClient->getInstanceProfileCredentials() #1 C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\Credentials\AbstractRefreshableCredentials.php(54): Aws\Common\Credentials\Refreshable in C:\xampp\htdocs\aws-php\vendor\aws\aws-sdk-php\src\Aws\Common\InstanceMetadata\InstanceMetadataClient.php on line 85

How can I fix the above error?

8 4 2
2,300 points

1 Answer

0 votes

Solution :

I had also faced such issues earlier. My mistake was I was using code as shown below

return DynamoDbClient::factory(array(
  'version' => 'latest',
  'region'  => AWS_REGION,
  'key' => AWS_KEY,
  'secret'  => AWS_SECRET

That was perfect for  aws/aws-sdk-php version 2.8.5 but when the composer automatically installed the version 3.2.0, I also got the above error. So just changed the way I made the call to as shown below

return DynamoDbClient::factory(array(
  'version' => 'latest',
  'region'  => AWS_REGION,
  'credentials' => array(
    'key' => AWS_KEY,
    'secret'  => AWS_SECRET,

Without changing my call, the apache php was searching for the ~/.aws/credentials file using a HOME environment variable in my case it was empty. If you want then you  can check its value by running below command

php -r 'var_dump(getenv("HOME"));'

It fixed my issue.

5 2 1
4,980 points

Related questions

0 votes
1 answer 11 views
Problem: I am trying to create a Security Group using the AWS SDK but it is failing to authenticate it. For a very specific Access Key and Secret Key I have already provided the Administrative rights and then also it fails to validate. I also tried ... .java:1146) at com.sunil.demo.ec2.SetupEC2.createSecurityGroup(SetupEC2.java:84) at com.sunil.demo.ec2.SetupEC2.main(SetupEC2.java:25)
asked Aug 24 Raphael Pacheco 4.9k points
1 vote
1 answer 28 views
Problem : I am trying to learn Android Billing. Recently I have started implementing the Google in app billing to my current Application. I have already created the SKU product id and I have also implemented the billing process in the code. If I try to test my in-app billing ... with my test account. I think I have made big blunder in my code. But I am unable to figure it out. Please guide me.
asked May 19 Martin K 6.6k points
0 votes
1 answer 1.6K views
Problem : I want to setup the Amazon Linux AMI(ami-f0091d91) also I have the script that runs a copy command to copy from the S3 bucket as follows: aws --debug s3 cp s3://aws-codedeploy-us-west-2/latest/codedeploy-agent.noarch.rpm . ... awscli.customizations.s3.s3handler - DEBUG - Exception caught during task execution: A client error (403) occurred when calling the HeadObject operation: Forbidden
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 505 views
Problem : I am facing following error : An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied Whenever I tried to get folder from my S5 bucket using following command : aws s5 cp s5://bucket-name/data/all-data/ . --recursive My IAM permissions for the ... ": [ "arn:aws:s5:::bucketname/*" ] } ] } What should I update to be able to execute copy and ls successfully?
asked Dec 5, 2019 alecxe 7.5k points