• Register
0 votes
589 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 16 views
16 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
1 vote
1 answer 30 views
30 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, 2020 Martin K 6.6k points
0 votes
1 answer 2K views
2K 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 772 views
772 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
0 votes
1 answer 1.1K views
1.1K views
Problem : I am facing following error "500 Internal Server Error - LogicException: Unable to guess how to get a Doctrine instance from the request information". Below is my controller action definition: /** * @Route("/gatheractor/{actor_name}/{gather_id}") * @Template() */ public function createActorAction(Actor $actor, Gather $gather) { // ... } How can I fix the above error?
asked Feb 18, 2020 mphil 2.3k points
0 votes
1 answer 387 views
387 views
Problem : I want to set up the hello world example with AWS lambda and serving it through the api gateway. I clicked a "Create a Lambda Function", which set up a api gatway and selected a Blank Function option. I added a lambda function found on AWS ... response { "message": "Internal server error" }. And my logs say "Execution failed due to configuration error: Malformed Lambda proxy response".
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 25 views
0 votes
0 answers 50 views
50 views
Problem: Is it possible for someone to check my code which I have recently tried to create using the YAML for Cloudformation for some unknown strange reasons I am facing the following error. I am new to YAML. Error: CREATE_FAILED    AWS::EC2::Instance  Ec2InstanceOne  The ... MySubnet: Type: AWS::EC2::Subnet Properties: AvailabilityZone: eu-west-1a CidrBlock: 192.168.1.0/24 VpcId: !Ref MyVpc
asked Jun 22, 2020 Raphael Pacheco 4.9k points
0 votes
0 answers 95 views
95 views
Problem: I have only managed to have the elementary knowledge on AWS. Currently I am trying to download all of the available files from the s3 bucket to the local machine. I have already installed AWS cli. After that I have tried to use the aws configure to ... the ListObjectsV2 operation: The AWS Access Key Id you provided does not exist in our records. Kindly guide me in fixing above AWS error.
asked Jun 22, 2020 Raphael Pacheco 4.9k points