0
1

More than 3 years have passed since last update.

CodeCommitレポジトリを共有してレビュー「だけ」して貰うための権限設定

Posted at

開発チーム外のメンバーに、CodeCommitレポジトリ上のコードを見て貰いたいことがある。
pushやプルリクの必要はなく、調査協力やアドバイスのためにレビューだけをお願いしたいという時に、設定すべき権限一式と手順についてメモ。

前提

  • AWS SSOを使う。
    • SSOドメインは東京リージョンに作成。
    • アクセス権限セット名はCodeReviewerとする。
  • git-remote-codecommit(GRC)を使ってクローンする。

権限セットの準備

アクセス権限セットを作成し、CodeCommitレポジトリのあるAWSアカウントとレビュー用SSOユーザー(またはグループ)に紐付ける。

CodeReviewer
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "CodeCommitRepositorySpecificAction",
            "Effect": "Allow",
            "Action": [
                "codecommit:EvaluatePullRequestApprovalRules",
                "codecommit:BatchGet*",
                "codecommit:GitPull",
                "codecommit:Describe*",
                "codecommit:BatchDescribe*",
                "codecommit:Get*",
                "codecommit:List*"
            ],
            "Resource": [
                "arn:aws:codecommit:ap-northeast-1:123456789012:<レポジトリ名>"
            ]
        },
        {
            "Sid": "CodeCommitGlobalAction",
            "Effect": "Allow",
            "Action": [
                "codecommit:ListRepositoriesForApprovalRuleTemplate",
                "codecommit:GetApprovalRuleTemplate",
                "codecommit:ListApprovalRuleTemplates",
                "codecommit:ListRepositories"
            ],
            "Resource": "*"
        }
    ]
}

レビュワーに手順を伝達

アクセス権限セットを作り、紐付けを行ったら、レビュワーに以下の手順を伝えてログインして貰う。

1. プロファイル作成手順

ログイン用のAWSプロファイルはホームディレクトリの.aws/configを編集して作る。
aws configure sso --profile reviewer-profileとして、インタラクティブに作成することもできる。

reviewer-profile
[profile reviewer-profile]
sso_start_url=https://<SSO URL>.awsapps.com/start
sso_region=ap-northeast-1
sso_account_id=123456789012
sso_role_name=CodeReviewer
region=ap-northeast-1
output=json

2. ログイン&クローン手順

上記のプロファイルを使ってログイン後、git cloneして完了。
あとはIDEなりエディタなりでレビューして貰う。

ログイン手順
% pip install git-remote-codecommit
% aws sso login --profile <プロファイル名>
% export AWS_PROFILE="<プロファイル名>"
% git clone codecommit::ap-northeast-1://<レポジトリ名>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1