Created
May 24, 2017 17:44
-
-
Save mario21ic/9973ad73b3647cfa28e4a191e60b4e56 to your computer and use it in GitHub Desktop.
Script to use in user data to aws ec2
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 | |
BUCKET="mybucket.deploy" | |
ENVIRONMENT="dev" | |
LATEST="/tmp/latest.zip" | |
APP_DIR="/var/www/web" | |
latest=$(aws s3 ls s3://$BUCKET/$ENVIRONMENT/ --recursive | sort | tail -n 1 | awk '{print $4}') | |
aws s3 cp s3://$BUCKET/$latest $LATEST | |
sudo mkdir -p $APP_DIR && unzip -qo $LATEST -d $APP_DIR | |
rm -f $LATEST | |
chown ec2-user:ec2-user -R $APP_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment