【新サービス】AWS CodeCommitがリリースされました!

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

昨年11月のAWS re:Invent 2014で発表されたCode3兄弟(AWS CodeDeployAWS CodeCommitAWS CodePipeline)。CodeDeployだけが先行してリリースされていましたが、AWS Summit 2015 New Yorkでの発表によって、ついに出揃いました!

今回はまず、CodeCommitを試してみました!

やってみた

リポジトリを作成する

CodeCommitは、現時点ではバージニアリージョンでのみのリリースとなります。CodeCommit管理コンソール二アクセスし、[Get started]ボタンをクリックします。

AWS_CodeCommit_Management

[Create new repository]画面が表示されますので、リポジトリ名を指定して[Create repository]ボタンをクリックします。

AWS_CodeCommit_Management 2

すると以下のようにリポジトリが作成されます。リポジトリをクリックすると... AWS_CodeCommit_Management 3

詳細画面が表示されます。

AWS_CodeCommit_Management 4

AWS CLIをバージョンアップする

CodeCommitが使えるAWS CLIにバージョンアップします。現時点では、pipでは1.7.28までしかインストールできませんので、直接tarballをダウンロードしてからインストールします。

$ tar xvzf awscli-1.7.38.tar.gz
$ cd awscli-1.7.38
$ python setup.py install
$ aws --version
aws-cli/1.7.38 Python/2.7.9 Darwin/14.4.0

ローカルPCからpushしてみる

まず、aws configureで、CodeCommitに対しての権限を持つIAMユーザーのCredentialを登録します。

$ aws configure

今回は以下のようなソースコードを用意しました。

$ ls -alF
-rw-r-----@ 1 smokeymonkey  monkey  22272  7 10 13:16 sonna-kotomo-aroukato-1.4.template

普通にgitを使うときと同じように、初期設定をします。

$ git init
$ git config user.name "smokeymonkey"
$ git config user.email "smokeymonkey@gmail.com"

リポジトリへのアクセスには、AWS CLIでcredential helperを使うようにします。

$ git config credential.helper '!aws codecommit credential-helper $@'
$ git config credential.UseHttpPath true

リモートリポジトリを登録します。

$ git remote add sonna-kotomo-aroukato https://git-codecommit.us-east-1.amazonaws.com/v1/repos/sonna-kotomo-aroukato

そしてcommit。

$ git add -A
$ git commit
[master (root-commit) aace6a9] 1st commit
 1 file changed, 548 insertions(+)
 create mode 100644 sonna-kotomo-aroukato-1.4.template

Pushします。

$ git push sonna-kotomo-aroukato master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 4.98 KiB | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
To https://git-codecommit.us-east-1.amazonaws.com/v1/repos/sonna-kotomo-aroukato
 * [new branch]      master -> master

簡単!

さいごに

プライベートなGitリポジトリを簡単に構築することができました。ハードウェアにもリソースにも気をとられることなく、セキュアで、もちろん使った分だけしかコストがかかりません。CodeDeployやCodePipelineと組み合わせて継続的インテグレーションが可能になります!