AWS-codeCommit

여러가지 SCM(source controll manager)가 있지만 그 중에서 AWS 솔루션인 codecommit에 대해서 작성 하였다.

aws cli command

# 전체 조회
aws codecommit list-repositories

# repo 명만
aws codecommit list-repositories |jq -r '.[].[].repositoryName'

# 특정 repo 상세 조회 
aws codecommit get-repository --repository-name MyDemoRepo

ssh 작업

  1. SSH 키를 생성하지 않았다면, 다음 명령어를 사용하여 SSH 키를 생성합니다:

     ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. AWS Management Console에 로그인하여 https://console.aws.amazon.com/iam/에서 IAM 콘솔을 엽니다.

내 보안 인증 정보에서 CodeCommit 보안 인증 정보를 직접 보고 관리할 수 있습니다. 사용자 세부 정보 페이지에서 보안 인증 정보 탭을 선택한 다음 SSH 퍼블릭 키 업로드를 선택합니다. SSH 퍼블릭 키의 콘텐츠를 필드에 붙여넣은 후 SSH 퍼블릭 키 업로드를 선택합니다. SSH 키 ID(예: APKAEIBAERJR2EXAMPLE)에 정보를 복사하거나 저장합니다.

  1. ~/.ssh/config 내용 추가

Host git-codecommit.*.amazonaws.com
  User APKAU6GDUR34DRR     >> 콘솔에서 확인한 key 
  IdentityFile ~/.ssh/kth.pem

clone script

     #!/bin/bash

     # AWS CodeCommit에서 모든 저장소 목록을 가져옵니다.
     REPO_NAMES=$(aws codecommit list-repositories | jq -r '.repositories[].repositoryName')

     # 각 저장소를 클론하고, 원격 저장소를 추가합니다.
     for REPO_NAME in $REPO_NAMES; do
         # 저장소의 SSH URL을 가져옵니다.
         REPO_URL=$(aws codecommit get-repository --repository-name $REPO_NAME | jq -r '.repositoryMetadata.cloneUrlSsh')
         
         # 저장소를 클론합니다.
         git clone $REPO_URL
         
         # 클론한 디렉토리로 이동합니다.
         cd $REPO_NAME
         
         # 원격 저장소를 추가합니다.
         git remote add origin $REPO_URL
         
         # 디렉토리에서 나옵니다.
         cd ..
     done

Last updated