Created
December 27, 2015 18:23
-
-
Save juliensimon/d699584bf5e755ba5a6e to your computer and use it in GitHub Desktop.
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 | |
# Author: Julien Simon <[email protected]> | |
# Connect to a Redshift cluster using psql | |
if ([ -z $1 ] || [ -z $2 ] || [ -z $3 ]) | |
then | |
echo "Usage: psqlRedshift CLUSTER_NAME DATABASE_NAME USER_NAME" | |
exit | |
fi | |
psql=/usr/local/bin/psql | |
redshift_port=`aws redshift describe-clusters --cluster-identifier $1 --query "Clusters[0].Endpoint.Port"` | |
redshift_host=`aws redshift describe-clusters --cluster-identifier $1 --query "Clusters[0].Endpoint.Address" | sed -e 's/"//g'` | |
echo "Connecting to database "$2" on "$redshift_host":"$redshift_port | |
$psql -h $redshift_host -p $redshift_port -U $3 "dbname=$2 sslmode=require" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment