Reputation: 25
Following the Laravel Vapor documentation for file uploads (https://docs.vapor.build/1.0/resources/storage.html#file-uploads), I'm encountering the following error when I try to upload the file from localhost to S3:
POST http://localhost:8000/vapor/signed-storage-url 500 (Internal Server Error)
The laravel log states the following:
Unable to issue signed URL. Missing environment variables: AWS_BUCKET, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY at Http\\Controllers\\SignedStorageUrlController.php:107
All of those environment variables are defined in the .env file.
Any ideas on how to overcome this issue?
Upvotes: 2
Views: 2429
Reputation: 474
To use the S3 storage with vapor locally, you'll need to set the AWS environment variables into your .env.
These variables:
AWS_BUCKET
, AWS_DEFAULT_REGION
, AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
.
When running in the vapor, these variables are injected into your environment during execution time.
Upvotes: 0
Reputation: 762
You need to update your env.production or whatever environment you are using
vapor env:pull production // or staging etc
Add those aws values in there then
vapor env:push production
Then deploy to your environment and your environment variables will be used. Your .env is only local
Upvotes: 0
Reputation: 1148
Laravel Vapor uses the $_ENV array to read the environment variables. Mine was empty:
dd($_ENV) = []
After some research, I found out that php.ini has to be set to allow/enable PHP to set the $_ENV variables from -env. My local php-fpm Docker development setup had this disabled by default. I just had to update the variables_order = "EGPCS" to allow this to happen and then Vapor works correctly.
&& sed -E -i -e "s/variables_order.*/variables_order = \"EGPCS\"/g" "$PHP_INI_DIR/php.ini"
I'm using Docker, but I assume if you enable or amend this in a local php.ini file you can get this working also.
Upvotes: 1
Reputation: 244
Set AWS_BUCKET, AWS_DEFAULT_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY inside secrets area of Vapor dashboard or cli.
Upvotes: 0