Symfony 4 & Amazon S3 – AWS credentials not working

  amazon-s3, amazon-web-services, php, symfony, ubuntu

I have a Symfony 4 project that is deployed to the Digital Ocean Ubuntu server.
In order to store files, I am using Amazon S3 bucket.
I’ve used aws/aws-sdk-php library to interact with the Amazon S3 bucket.
I’ve created the global credentials file at ~/.aws/credentials and managed to make it work.

The problem is that it doesn’t work on the server.
I copied the credentials file to the server’s ~/.aws/ directory, but I am getting this error.

Error retrieving credentials from the instance profile metadata server. (Client error: `GET http://169.254.169.254/latest/meta-data/iam/security-credentials/` resulted in a `404 Not Found` response: not found)

I did some research on this error – it seems that the php server isn’t finding the credentials file.
How do I fix this?

Source: Symfony Questions

LEAVE A COMMENT