laravel-aws-secrets-manager
laravel-aws-secrets-manager copied to clipboard
putenv() and use of ServiceProvider "boot" method
Hi, thanks for making this package. It's exactly what I was looking for. Two things I noticed that may or may not be a problem:
-
In LaravelAwsSecretsManager
putenv()
is used and laterenv()
. I think this only works if the env variables do not exist in the .env file. In my testing, if the .env file contains the lineMAIL_PASSWORD=
I can't update the password with values from AWS. A call toconfig()
to update the config value will work, though. -
I tried to set the REDIS_PASSWORD from AWS, and discovered this problem. The framework's RedisServiceProvider reads the config in
register()
, whichs runs before LaravelAwsSecretsManagerServiceProvider'sboot()
. So when the Redis password is retrieved, the config is the original config, with no values from AWS yet. And if Redis requires a password, it fails.
@audunru, @swilla, I also have this problem, the putenv() params can't be used in config/database.php which uses the .env DB params, do you have any ideas about how to resolve this issue?
You can see the below screenshot to check the loading orders
FYI:
@xingtianyoulong One solution for this package would be to load the secrets earlier in the process, for instance in bootstrap/app.php
. If you are trying to store any kind of secret in AWS which is needed by a service that loads before LaravelAwsSecretsManagerServiceProvider, you can run into problems. RedisServiceProvider is one such example.
If we load secrets in boostrap/app.php
so we can use them in database.php
for example, we can't store them in cache since in boostrap/app.php
Cache is not already available, right?
Guys, Anyone find the solution for that. I have tried the package for load db and all credential from aws secret manager, it fails to load db details. It will very helpful if anyone solution / package for that