How to clone a CodeCommit repo inside a Cloud9 environment?
Cloud9 is Amazon’s cloud-based IDE that makes writing and building projects a breeze. There are no licensing fees involved (unlike PHPStorm or other similar IDEs) and the added benefit is that you get tight integration with AWS services like Lambda and CodeCommit.
A common use case for using Cloud9 is working collaboratively on a project, that’s hosted in Git (version control). And what’s better than using Amazon’s native Git repo hosting, called CodeCommit?
In this short tutorial, you’ll learn how to clone a CodeCommit repo inside a Cloud9 development environment. We will assume that you already have a Cloud9 environment created, you have logged in and there is an existing CodeCommit repo.
Steps to clone a CodeCommit repo inside Cloud9
While in the terminal of your Code9 environment, run the following commands:
git config --global credential.helper '!aws codecommit credential-helper $@' git config --global credential.UseHttpPath true
What this does is it tells the Git CLI to use the AWS CLI whenever Git HTTP authentication is required (when cloning, pulling, pushing code). Additionally, the second line tells the Git CLI to enforce strict HTTPs pulling instead of HTTP.
The final result will be that whenever you enter the Cloud9 environment and attempt to clone a CodeCommit repo, the AWS helper will kick in and use temporary AWS credentials that represent YOU (the current Cloud9 user) before CodeCommit while doing Git operations.
The final step would be to clone a Git repo inside Cloud9. Remember to always use the HTTPs clone URL instead of the SSH one, because SSH will fallback to private key-based authentication. Something we haven’t configured above, so it won’t work.