Skip to content

Instantly share code, notes, and snippets.

@lex64
Last active August 16, 2023 16:39
Show Gist options
  • Save lex64/9a67e5f9d47c582ab8f250fb1e82320d to your computer and use it in GitHub Desktop.
Save lex64/9a67e5f9d47c582ab8f250fb1e82320d to your computer and use it in GitHub Desktop.
Generate Laravel .env file from AWS Parameters Store
#!/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
@vrakita
Copy link

vrakita commented Oct 24, 2019

Great work!

@yashtomer
Copy link

Superb!

@zoix
Copy link

zoix commented Oct 2, 2022

Thanks for this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment