Setting Up a CodeCommit Repository
Here’s a step-by-step guide to create an AWS CodeCommit repository, access it from your host through SSH, and perform basic operations like cloning, adding, and pushing data.
1. Create the codecommit repository
Repository name: datacenter-repo
2. Generate Public Key on the host
$ssh-keygen
3. Copy the generate public key and past it the IAM user security credentials.
$ cat /root/.ssh/id_rsa_pub
4. Create the IAM user and go into the security credentials and upload the ssh public key.
4. Configure SSH for CodeCommit.
Create the file with config and put the data as below
Host git-codecommit.*.amazonaws.com
User <IAM-SSH-Key-ID>
IdentityFile ~/.ssh/id_rsa
~ on ☁️ (us-east-1) ➜ vi /root/.ssh/config
5. Clone the new repository on host under /root
/ on ☁️ (us-east-1) ➜ sudo git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/datacenter-repo
Recommended by LinkedIn
6. Add the contents of /root/pyapp directory to this repository. we already have source code in this directory.
/ on ☁️ (us-east-1) ➜ cp -R /root/pyapp/* /root/.ssh/datacenter-repo/
7. Set the git user and email to commit your code, you can use any email ID and user name for that.
datacenter-repo on master [+] on ☁️ (us-east-1) ➜ git config --global user.name "pravin"
datacenter-repo on master [+] on ☁️ (us-east-1) ➜git config --global user.email "pravin@yahoo.in"
8. Then add, commit, and push the changes to the repository.
datacenter-repo on master [?] on ☁️ (us-east-1) ➜ git add .
datacenter-repo on master [+] on ☁️ (us-east-1) ➜ git commit -m "Initial commit with pyapp contents"
output:
[master (root-commit) 583cd48] Initial commit with pyapp contents
1 file changed, 1 insertion(+)
create mode 100644 app.py
datacenter-repo on master on ☁️ (us-east-1) ✖ git push -u origin master
Output:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 246 bytes | 246.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Validating objects: 100%