diff --git a/src/AwsServiceProvider.php b/src/AwsServiceProvider.php index 60b1b69..f80aed9 100644 --- a/src/AwsServiceProvider.php +++ b/src/AwsServiceProvider.php @@ -1,4 +1,6 @@ -app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes( - [__DIR__.'/../config/aws_publish.php' => config_path('aws.php')], + [__DIR__ . '/../config/aws_publish.php' => config_path('aws.php')], 'aws-config' ); } elseif ($this->app instanceof LumenApplication) { @@ -44,13 +46,21 @@ public function boot() public function register() { $this->mergeConfigFrom( - __DIR__.'/../config/aws_default.php', + __DIR__ . '/../config/aws_default.php', 'aws' ); $this->app->singleton('aws', function ($app) { $config = $app->make('config')->get('aws'); + // validate key and secrets, empty value will stop aws sdk from looking for the correct credentials + if ( + !isset($config['credentials']['key']) || !isset($config['credentials']['secret']) + || empty($config['credentials']['key']) || empty($config['credentials']['secret']) + ) { + unset($config['credentials']); + } + return new Sdk($config); }); @@ -66,5 +76,4 @@ public function provides() { return ['aws', 'Aws\Sdk']; } - }