Last active
August 16, 2023 16:39
-
-
Save lex64/9a67e5f9d47c582ab8f250fb1e82320d to your computer and use it in GitHub Desktop.
Generate Laravel .env file from AWS Parameters Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PARAMATER="laravel-env" | |
REGION="eu-central-1" | |
WEB_DIR="/var/www/laravel" | |
WEB_USER="www-data" | |
# Get parameters and put it into .env file inside application root | |
aws ssm get-parameter --with-decryption --name $PARAMATER --region $REGION --query Parameter.Value | sed -e 's/^"//' -e 's/"$//' -e 's/\\n/\n/g' -e 's/\\//g' > $WEB_DIR/.env | |
# Clear laravel configuration cache | |
cd $WEB_DIR | |
chown $WEB_USER. .env | |
sudo -u $WEB_USER php artisan config:clear |
Superb!
Thanks for this 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great work!