Skip to content

Instantly share code, notes, and snippets.

@nolram
Last active September 1, 2022 22:26
Show Gist options
  • Save nolram/ccd891d6b97f9df2e116bee5486a0c06 to your computer and use it in GitHub Desktop.
Save nolram/ccd891d6b97f9df2e116bee5486a0c06 to your computer and use it in GitHub Desktop.
Script to clone all repositories from AWS CodeCommit on a specific AWS Account.
#/bin/bash
# Script to clone all repositories from AWS CodeCommit on a specific AWS Account.
# This script clone ssh repositories, but it can be changed to use https
# Requirements
# aws-cli - https://aws.amazon.com/pt/cli/
# jq - https://stedolan.github.io/jq/
# git
profile=""
region="us-east-1"
projects=$(aws --profile ${profile} --region ${region} --no-paginate codecommit list-repositories | jq -r '.repositories[] | { repositoryName} | join("")')
for project in $projects
do
echo "Cloning $project"
if ! git clone ssh://git-codecommit.${region}.amazonaws.com/v1/repos/${project} "${project}" 2>/dev/null && [ -d "${project}" ] ; then
echo "Clone failed because the folder ${project} exists"
else
echo "Clone success"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment