aws/aws-sdk-php-laravel

Overridden config for Dynamo DB not working

reedknight opened this issue · 2 comments

Please fill out the sections below to help us address your issue.

Version of AWS SDK for PHP?

"name": "aws/aws-sdk-php",
"version": "3.120.0",

Version of AWS Service Provider for Laravel?

"name": "aws/aws-sdk-php-laravel",
"version": "3.4.0",

Version of Laravel (php artisan --version)?

Laravel Framework 6.4.0

Version of PHP (php -v)?

PHP 7.2.24 (cli) (built: Oct 25 2019 04:22:41) ( NTS )

What issue did you see?

Overridden config for DynamoDB not working.

I am using Dynamo DB locally through docker. I am able to connect to Local Dynamo DB from Laravel using the endpoint config option as localhost:8001(Running DynamoDB on Port 8001) in the main/global section of the config array. However, doing so points all other AWS services to localhost:8001; which is undesirable. My objective is to use different config for Dynamo DB and other AWS services.

The documentation has a section like the following:

// You can override settings for specific services

'Ses' => [
    'region' => 'us-east-1',
]

My understanding from the above section of the documentation is that this package allows overriding config for specific services from the main config which would ideally solve my purpose.

Steps to reproduce

If you have a runnable example, please include it as a snippet or link to a repository/gist for larger code examples.

File: config/aws.php

<?php

use Aws\Laravel\AwsServiceProvider;

return [

    /*
    |--------------------------------------------------------------------------
    | AWS SDK Configuration
    |--------------------------------------------------------------------------
    |
    | The configuration options set in this file will be passed directly to the
    | `Aws\Sdk` object, from which all client objects are created. This file
    | is published to the application config directory for modification by the
    | user. The full set of possible options are documented at:
    | http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/configuration.html
    |
    */
    'credentials' => [
        'key'    => env('AWS_ACCESS_KEY_ID', ''),
        'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
    ],
    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    'version' => 'latest',
    'ua_append' => [
        'L5MOD/' . AwsServiceProvider::VERSION,
    ],
    // You can override settings for specific services
    'dynamodb'=>[
        'endpoint' => (config('app.env') == 'local') ? 'http://localhost:8001' : env('AWS_URL', ''),
    ]
];

Additional context

Any additional information relevant to the issue, for example PHP/environment config settings if the issue is related to memory or performance.

change 'endpoint' node level, it works.@reedknight

<?php

use Aws\Laravel\AwsServiceProvider;

return [

    /*
    |--------------------------------------------------------------------------
    | AWS SDK Configuration
    |--------------------------------------------------------------------------
    |
    | The configuration options set in this file will be passed directly to the
    | `Aws\Sdk` object, from which all client objects are created. This file
    | is published to the application config directory for modification by the
    | user. The full set of possible options are documented at:
    | http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/configuration.html
    |
    */
    'credentials' => [
        'key'    => env('AWS_ACCESS_KEY_ID', ''),
        'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
    ],
    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    'version' => 'latest',
    'ua_append' => [
        'L5MOD/' . AwsServiceProvider::VERSION,
    ],
    // You can override settings for specific services
    'endpoint' => (config('app.env') == 'local') ? 'http://localhost:8001' : env('AWS_URL', ''),
];

@reedknight can you verify @lduhejian solution?

Would like to close this, if it has been solved.