Skip to content

Instantly share code, notes, and snippets.

@ddepaoli3
Created November 30, 2016 10:56
Show Gist options
  • Save ddepaoli3/bd6f4a539a5a1e4b2a57ae440f7db096 to your computer and use it in GitHub Desktop.
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
#!/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