mardi 27 octobre 2015

laravel and aws credential provider

I want to use AWS's credential provider to memoize my credentials from a chain. ie: use environment variables if applicable, if not - checkout credentials ini file, else use the ec2 instance profile provider.

in my config/queue.php

<?php
$provider = \Aws\Credentials\CredentialProvider::defaultProvider();
$credentials = $provider()->wait();

return [
    ...
    'connections' => [
        ...
        'sqs' => [
            'driver' => 'sqs',
            'key' => null,
            'secret' => null,
            'credentials' => $credentials,
            'queue'  => env('AWS_QUEUE_URL'),
            'region' => env('AWS_REGION', 'us-east-1'),
        ],

which worked when I was testing artisan's queue:work functionality, but when I tried to load a route for a web app - it blows up and complains about classes not loading.

Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist' in /Users/MyUser/Sites/Mysite.dev/httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 737

This error doesn't exist when I remove this config setup for the credentials.

Is there a better way / spot to load these credentials?

I don't want to hard code key/secret into the app or deal w/ it in a .env file either.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire