AWS CodeCommit Deprecation: A Complete Guide to Migrating Your Repositories to GitHub
To be clear, I was not a big fan of AWS CodeCommit. It was easy to set up and use, but if you compare it with other Git providers like Github or Gitlab, CodeCommit lacks many features.
Anyway, If you have been using CodeCommit to manage your source code, now is the time to migrate your repositories to a more popular and widely supported platform like GitHub.
After careful consideration, we have made the decision to close new customer access to AWS CodeCommit, effective July 25, 2024.
In recent times, AWS announced the deprecation of AWS CodeCommit, its fully managed source control service that hosts Git repositories. This blog post will guide you through a step-by-step process to seamlessly migrate your existing AWS CodeCommit repositories to GitHub. By the end of this guide, you’ll be equipped with the knowledge to not only migrate your code but also optimize your workflow on GitHub.
Prerequisites for Migration
- AWS CLI is installed and configured with access to your AWS account.
- Git is installed on your local machine.
- A GitHub account with the necessary permissions to create repositories.
- Owner access to the AWS CodeCommit repositories you plan to migrate.
Steps to migrate
Let’s break down the migration process into simple, actionable steps:
Step 1- Audit Your CodeCommit Repositories
This step is very important, before starting to migrate, it’s crucial to perform an audit of your existing CodeCommit repositories. Identify which repositories need to be migrated and check for:
- Large file sizes
- Branch protection rules
- Pull requests in progress
- Git hooks or any custom scripts
- Access permissions (to replicate on GitHub)
You can list all your repositories using the AWS CLI:
aws codecommit list-repositories
Step 2- Create a New GitHub Repository
If you don’t have already. For each CodeCommit repository you plan to migrate, create a corresponding repository on GitHub. TO do so , you can do it from Github console or using Github CLI commands as shown below:
Using Console >
- Log in to your GitHub account.
- Click on New Repository.
- Enter the repository name, and description, and set it to Public or Private as needed.
- Click Create Repository.
Or, use the GitHub CLI
gh repo create <your-repo-name> --private
Step 3- Clone Your CodeCommit Repository Locally
Use the AWS CLI to clone your CodeCommit repository to your local machine
git clone https://git-codecommit.<region>.amazonaws.com/v1/repos/<codecommit-repo-name>
# CD to the cloned project dir
cd <codecommit-repo-name>
Step 4- Add GitHub as a New Remote
Once you have the repository cloned locally, add your new Github repository as a remote:
git remote add github https://github.com/<your-username>/<github-repo-name>.git
You can verify the remotes using:
git remote -v
The expected output should be as below :
origin https://git-codecommit.<region>.amazonaws.com/v1/repos/<codecommit-repo-name> (fetch)
origin https://git-codecommit.<region>.amazonaws.com/v1/repos/<codecommit-repo-name> (push)
github https://github.com/<your-username>/<github-repo-name>.git (fetch)
github https://github.com/<your-username>/<github-repo-name>.git (push)
Step 5- Push All Branches and Tags to GitHub
To ensure you migrate everything, push all branches and tags to GitHub:
# Push all branches
git push github --all
# Push all tags
git push github --tags
Step 6- Migrate Branch Protection Rules (Optional)
If you had branchs protection rules on AWS CodeCommit, replicate those in your GitHub repository settings:
- Go to Settings > Branches > Add Rule.
- Configure branch protection as needed, such as requiring pull request reviews, status checks, or code owner approvals.
Step 7- Migration Validation
Once the push is complete, verify that all files, branches, and tags have been successfully migrated to the Github repo. You can do this by browsing your repository online or by cloning it to another location and checking it locally.
Step 8- Update CI/CD Pipelines and fix protected branches
If you have CI/CD pipelines set up that interact with your repositories, such as GitLab, GitHub or AWS CodePipeline, update their configuration to reflect the new repository URL.
Most of the DevOps prepare to use the Github Actions CICD tool instead of CodePipeline if they are using Github repo already, why? GitHub Actions is natively integrated into GitHub, making it easier to set up and trigger workflows directly from GitHub events like pull requests, commits, or merges.
Another reason is cost Efficiency since they already paid for Github plans. In addition to the ability of reusability of github workflows which allow you to abstract and reuse code in multiple repositories.
However, if you’re heavily invested in the AWS ecosystem ( like me 🤝 ), it makes sense to continue leveraging AWS CodePipeline, especially since it offers seamless integrations with other AWS services like CodeBuild, CodeDeploy, Elastic Beanstalk, ECS, and Lambda.
Step 9- Disable or Delete Old CodeCommit Repositories
Please be aware that this action cannot be undone. Once you’ve confirmed that your GitHub repositories are working correctly, disable or delete the old CodeCommit repositories:
aws codecommit delete-repository --repository-name <codecommit-repo-name>
Or from the AWS CodeCommit console:
Conclusion
Migrating from AWS CodeCommit to GitHub can be a straightforward process if planned properly. By following the steps outlined in this guide, you can seamlessly transition to GitHub while taking advantage of its rich features and extensive community support.
Feel free to share your migration journey and any challenges you faced in the comments section below. Happy coding!
Thank you 🙏