Created
November 30, 2016 10:56
-
-
Save ddepaoli3/bd6f4a539a5a1e4b2a57ae440f7db096 to your computer and use it in GitHub Desktop.
Tools for AWS codecommit. Add ssh key into your account and create new repository
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 | |
REPONAME="reponame" | |
REPODESC="Description of repo" | |
PROFILE="profile name" | |
REGION="eu-west-1" | |
USERNAME="" | |
SSH_KEY=`cat ~/.ssh/id_rsa.pub` | |
function add_key() { | |
echo "Username:" | |
read USERNAME | |
echo "Profile name" | |
read PROFILE | |
SSHPublicKeyId=`aws iam upload-ssh-public-key --user-name $USERNAME --ssh-public-key-body "$SSH_KEY" --profile $PROFILE | grep SSHPublicKeyId|sed s/.*\:\ //|sed s/\"//g` | |
echo -e "Insert these lines into your ~/.ssh/config file\n\n" | |
cat << EOF | |
Host $PROFILE-codecommit | |
HostName git-codecommit.$REGION.amazonaws.com | |
User $SSHPublicKeyId | |
IdentityFile ~/.ssh/id_rsa | |
EOF | |
} | |
function create-repository() { | |
echo "Repository name:" | |
read REPONAME | |
echo "Repository description" | |
read REPODESC | |
echo "Profile name" | |
read PROFILE | |
aws codecommit create-repository --repository-name $REPONAME --repository-description "$REPODESC" --profile $PROFILE --region $REGION | |
} | |
function help() { | |
echo $0 function_name | |
echo function_name: [add_key, create-repository] | |
} | |
if [ $# -eq 0 ] | |
then | |
help | |
else | |
$1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment