Introducing CodeCommit
CodeCommit is a secure, highly scalable, managed source control service that hosts private Git repositories. CodeCommit eliminates the need for you to manage your own source control system or worry about scaling its infrastructure. You can use CodeCommit to store anything from code to binaries. It supports the standard functionality of Git, so it works seamlessly with your existing Git-based tools.
Repositories in CodeCommit CANNOT be set to be public accessible.
Walk Through Steps:
- Create CodeCommit repository.
- Create connection credential.
- Setup local environment.
- Clone repository to local.
- Perform git actions.
Create CodeCommit repository
Name your repository, rest are optional.
Once created, CodeCommit shows you the options and how to connect to it. For simplicity, I use HTTPS.
You CANNOT use SSH if you login as root user.
Create Connection Credential
Credential used to access repositories in CodeCommit is created with IAM service. Click on the user you will be using to access your codes. You must grant user with appropriate permission. For more information, please refer here.
Select Security credentials.
Scroll down the page, you can create both credentials for SSH and HTTPS access. For this walk through, I will use HTTPS.
Credential will only show once after clicked “Generate credentials”.
Finish view with other action can be performed.
Setup local environment
Setup git (assume you have installed git locally) so git actions can be performed.
git config --global user.email “your@email.com”
git config --global user.name “yourname”
Clone repository to local
Clone the repository you created on CodeCommit. Enter your username and password obtained from IAM service step.
git clone https://your-repo-url-from-codecommit
Perform git actions
Put your code into the cloned repository(folder). Use git to add file and push it to CodeCommit repository
git status
git add .
git commit -m “your-comment-here”
git push
Verify on CodeCommit
Once pushed, check the file on CodeCommit. Click created repository.
If push successful, you will see the file pushed. Click the file to see the content.
That’s it!