illmatic's avatar

S3 Connection Issue

I'm really at wits end here.

I'm getting this issue but I'm 99% sure I've done everything correctly.

Error retrieving credentials from the instance profile metadata service. (cURL error 28: Connection timed out after 1004 milliseconds

When I'm uploading a file

$image = $request->file('media');
Storage::disk('s3')->put($folder, file_get_contents($image));

Here is my filesystems file

        's3' => [
            'driver' => 's3',
            'version' => 'latest',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            // 'credentials' => [
            //     'key' => env('AWS_ACCESS_KEY_ID'),
            //     'secret' => env('AWS_SECRET_ACCESS_KEY'),
            // ],
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),

Here is my .env shortend. Also copied keys directly from IAM Bucket name copied directly from https://console.aws.amazon.com/s3/home?region=us-east-1

AWS_ACCESS_KEY=AKIA....
AWS_SECRET_ACCESS=lKYE....
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=.........
AWS_URL=https://bucket-name.region.amazonaws.com

Lastly, here are my packages

        "league/flysystem-aws-s3-v3": "~1.0",
        "league/flysystem-cached-adapter": "~1.0",
        "league/flysystem-sftp": "~1.0",
0 likes
6 replies
woddell's avatar

It looks like your credentials are set up wrong. I'm pretty sure the code you've commented out is the correct way to send to the API, not sure why you've commented them out?

illmatic's avatar

I tried that before - hence the comments. If i enable it, I get this error

Credentials must be an instance of Aws\Credentials\CredentialsInterface, an associative array that contains "key", "secret", and an optional "token" key-value pairs, a credentials provider function, or false.

illmatic's avatar

Anyone face anything similar?

I set my bucket to public access and added the following policy

            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:DeleteObject",
                "s3:GetObject",
                "s3:PutObject"
            ],

Still having the same issue as above

illmatic's avatar
illmatic
OP
Best Answer
Level 1

So, I feel dumb, my env variables weren't the same as the filesystems.... Changed AWS_ACCESS_KEY to AWS_ACCESS_KEY_ID etc...

Please or to participate in this conversation.