概要
CodeCommitによるソース管理を始めるための開始方法をスクショを入れてまとめます。
基本的に以下内容に沿った内容となっています。
https://docs.aws.amazon.com/ja_jp/codecommit/latest/userguide/getting-started.html
リポジトリの作成
https://console.aws.amazon.com/codesuite/codecommit/home にアクセスし、リポジトリを作成を押下
リポジトリ名を設定し、作成
を押下。
SSHによるリポジトリのクローン
SSHでのリポジトリクローンはIAMユーザでのみ実行可能です。
CodeCommitように公開鍵を予め登録しておく必要があります。
$ ssh-keygen
$ cat ~/.ssh/id_rsa.pub
上記で出力された公開鍵をIAMユーザに登録します。
ローカルマシンの~/.ssh/config
に接続情報を記載します。
User
の値は公開鍵を登録した際のSSHキーIDです。
Host git-codecommit.*.amazonaws.com
User APKAZ6CO7NSLEFREIC4T
IdentityFile ~/.ssh/id_rsa
ローカルマシンでcloneを行います。
cloneのURLはCodeCommitで作成したリポジトリの画面から確認できます。
$ git clone ssh://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/practice_ripo
Cloning into 'practice_ripo'...
warning: You appear to have cloned an empty repository.
gitの使い方は基本的に同じなため割愛します。
CloudFormationによるリポジトリの作成
リポジトリの作成を自動化するため、CloudFormation
を使用し環境の作成を行います。
リポジトリを作成するだけであれば以下が最小単位となります。
AWSTemplateFormatVersion: '2010-09-09'
Resources:
codecommit:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: practice