aws / aws-sdk-php-laravel

A Laravel 5+ (and 4) service provider for the AWS SDK for PHP
http://aws.amazon.com/sdkforphp/
Apache License 2.0
1.64k stars 242 forks source link

Change the default region env variable to be consistent with the Laravel env example file #216

Open peppermintology opened 2 years ago

peppermintology commented 2 years ago

Describe the feature

Since v5.8 Laravel has provided example .env variables for configuring AWS settings, one of which is the AWS_DEFAULT_REGION key for configuring the default region (https://github.com/laravel/laravel/blob/5.8/.env.example). This package sets us-east-1 as the default region unless you define an alternative using the AWS_REGION key in your .env.

Suggest changing the environment key to use the same key that is already defined in the Laravel .env.example so that an effectively duplicate key does not need to be added. This also keeps it consistent with the other keys Laravel and the package share.

Use Case

No duplication of keys/values and keeps things consistent.

Proposed Solution

Update both config/aws_default.php and config/aws_publish.php to:

Replace

'region' => env('AWS_REGION', 'us-east-1'),

With

'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),

Other Information

No response

Acknowledgements

SDK version used

3.7

Environment details (OS name and version, etc.)

Fedora 36

RanVaknin commented 1 week ago

Hi there,

The AWS SDKs only support AWS_REGION env variable. AFAIK only the AWS CLI supports AWS_DEFAULT_REGION and at this point in time there is no plan to support this additional env variable in the AWS SDKs.

Can you describe how this is blocking you from using AWS_REGION? Does Laravel not have a fallback to this env variable? I don't have context about why this env variable was introduced in 5.8, It might have been an oversight on their part.

I suggest raising this issue in the Laravel repo to get a little more clarity on the matter.

Thanks, Ran~

bashar94 commented 1 week ago

New versions of Laravel can not recognise the .env key AWS_REGION, it was replaced by AWS_DEFAULT_REGION. Older versions of Laravel do not have this issue. That’s why I put the condition, if it is older then get the region from the AWS_REGION, if newer then use AWS_DEFAULT_REGION