• Register
0 votes
774 views

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] http://169.254.169.254/latest/meta-data/iam/security-credentials/)' 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

Please log in or register to answer this question.

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 33 views
33 views
Problem: the aws access key id needs a subscription for the service
asked Feb 19 Dan phillip 4.8k points
0 votes
1 answer 10 views
10 views
Problem: Please let me know any solution regarding this .. Invalid identity pool configuration. check assigned iam roles for this pool.
asked Apr 7 Ifra 34.7k points
0 votes
1 answer 40 views
40 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 2 views
2 views
Problem: Please solve it … Because I am unable to find out the solution .. How to get gcm registration id in android
asked 5 hours ago Ifra 34.7k points
0 votes
1 answer 41 views
41 views
Problem com.google.firebase.auth.firebaseauth is not linked. skipping initialization.
asked Feb 9 charles mathews 5.5k points
1 vote
1 answer 2 views
2 views
Problem: I deleted the old instance and created the new one with the AMI. I have been tracking my bill but still it is not eligible for free tier. I’ve been using only EC2 . Note that my first created instance is Micro instance with Ubuntu 13. How can I solve this ?
asked 5 days ago Raj Tyagi 14.4k points
0 votes
1 answer 5 views
5 views
Problem: I'm trying to send email on AWS SES. I'm using Laravel to do that, using the built in Mail methods. AWS is giving me the error: Error executing "SendRawEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.eu-west-1. ... ('Test Email '. time()) ->from('*Emails are not allowed*'); } To re-iterate, *Emails are not allowed* IS verified in AWS.
asked Apr 26 anika11 32k points
0 votes
1 answer 5 views
5 views
Problem: I'm trying to send email on AWS SES. I'm using Laravel to do that, using the built in Mail methods. AWS is giving me the error: Error executing "SendRawEmail" on "https://email.eu-west-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://email.eu-west-1. ... ('Test Email '. time()) ->from('*Emails are not allowed*'); } To re-iterate, *Emails are not allowed* IS verified in AWS.
asked Apr 24 ochena 22.1k points
0 votes
1 answer 6 views
6 views
Problem: I can't seem to delete it in AWS, It was not showing any options like delete or disassociate. AWS is charging me every month for Elastic IP address usage. I'm not even using them. Please help me, how to remove the EIP address?
asked Apr 25 sumaiya simi 43.9k points