CodeCommitリポジトリの復号化のCloudTrailログ確認
2021/11/17
ユーザーガイドAWS Key Management Service と AWS CodeCommit リポジトリの暗号化に記載がありますが、AWS CodeCommitリポジトリにソースコードを保存すると、AWS KMSのAWS所有キーaws/codecommitによって暗号化されて、git pullコマンドで復号化されるそうです。
ということで確認してみました。
目次
CloudTrailログ
git pullしたときであろうログを確認してみました。
invokedByがcodecommit.amazonaws.comでKMSのDecryptアクションが実行されていました。
aws:codecommit:idにリポジトリのIDがありました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
{ "eventVersion": "1.08", "userIdentity": { 〜中略〜 }, "invokedBy": "codecommit.amazonaws.com" }, "eventTime": "2021-11-17T12:02:33Z", "eventSource": "kms.amazonaws.com", "eventName": "Decrypt", "awsRegion": "us-east-1", "sourceIPAddress": "codecommit.amazonaws.com", "userAgent": "codecommit.amazonaws.com", "requestParameters": { "encryptionAlgorithm": "SYMMETRIC_DEFAULT", "encryptionContext": { "aws:codecommit:env-alg": "AES/256", "aws:codecommit:sig-alg": "HmacSHA256/256", "aws:codecommit:id": "xxxxx-xxxxxx-xxxxxx" } }, ~中略~ }, |
CodeCommitリポジトリIDの確認
リポジトリIDはget-repositoryコマンドで確認しました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$ aws codecommit get-repository --repository-name RepositoryName { "repositoryMetadata": { "creationDate": 1628481144.858, "defaultBranch": "master", "repositoryName": "RepositoryName", "cloneUrlSsh": "ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/RepositoryName", "lastModifiedDate": 1637150992.85, "repositoryDescription": "sample repository", "cloneUrlHttp": "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/RepositoryName", "repositoryId": "xxxxx-xxxxxx-xxxxxx", "Arn": "arn:aws:codecommit:us-east-1:123456789012:RepositoryName", "accountId": "123456789012" } } |
Athena検索時のSQLメモ
該当のCloudTrailログは、Athenaで検索して確認しました。
Athenaテーブルは、S3オブジェクトへのリクエストをCloudTrail, Athenaで識別する(パーティショニング)の方法で作成しています。
1 2 3 4 5 6 7 8 9 10 |
select * from "cloudtrail_events_db"."cloudtrail_partiion_table" where account='123456789012' and region='us-east-1' and year='2021' and month='11' and day='17' and eventsource='kms.amazonaws.com' and sourceipaddress='codecommit.amazonaws.com' and requestparameters like '%xxxxx-xxxxxx-xxxxxx%' |
KMS aws/codecommitのキーポリシー
対象のアカウントからのアクセスを許可するポリシーが設定されていました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
{ "Version": "2012-10-17", "Id": "auto-codecommit-2", "Statement": [ { "Sid": "Allow access through CodeCommit for all principals in the account that are authorized to use CodeCommit", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ], "Resource": "*", "Condition": { "StringEquals": { "kms:CallerAccount": "123456789012", "kms:ViaService": "codecommit.us-east-1.amazonaws.com" } } }, { "Sid": "Allow direct access to key metadata to the account", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": [ "kms:Describe*", "kms:Get*", "kms:List*" ], "Resource": "*" } ] } |
最後までお読みいただきましてありがとうございました!
「AWS認定資格試験テキスト&問題集 AWS認定ソリューションアーキテクト - プロフェッショナル 改訂第2版」という本を書きました。
![](https://www.sbcr.jp/wp-content/uploads/2023/01/9784815617929-1-407x596.jpg)
「AWS認定資格試験テキスト AWS認定クラウドプラクティショナー 改訂第3版」という本を書きました。
![](https://www.sbcr.jp/wp-content/uploads/2024/01/9784815625382-3-420x596.jpg)
「ポケットスタディ AWS認定 デベロッパーアソシエイト [DVA-C02対応] 」という本を書きました。
![](https://www.shuwasystem.co.jp//images/book/637791.jpg)
「要点整理から攻略するAWS認定ソリューションアーキテクト-アソシエイト」という本を書きました。
![](https://book.mynavi.jp/files/topics/135344_ext_06_0.jpg?v=1673514682)
「AWSではじめるLinux入門ガイド」という本を書きました。
![](https://www.yamamanx.com/wp-content/uploads/2023/12/81Rp5O9We6L._SY522_.jpg)
![@yamamanx](https://www.yamamanx.com/wp-content/plugins/lazy-load/images/1x1.trans.gif)
開発ベンダー5年、ユーザ企業システム部門通算9年、ITインストラクター5年目でプロトタイプビルダーもやりだしたSoftware Engineerです。
質問はコメントかSNSなどからお気軽にどうぞ。
出来る限りなるべく答えます。
このブログの内容/発言の一切は個人の見解であり、所属する組織とは関係ありません。
このブログは経験したことなどの共有を目的としており、手順や結果などを保証するものではありません。
ご参考にされる際は、読者様自身のご判断にてご対応をお願いいたします。
また、勉強会やイベントのレポートは自分が気になったことをメモしたり、聞いて思ったことを書いていますので、登壇者の意見や発表内容ではありません。
ad
ad
関連記事
-
-
Amazon Linux2(EC2)にEC-CUBE 4をインストール
こちらのHOMEお知らせ・コラムAmazon Linux2にEC-CUBE4.0 …
-
-
ブログのアーキテクチャをコストベースで見直しました
当ブログはAWSで構築しています。 アーキテクチャをコストを最重視して見直しまし …
-
-
Amazon SESの受信ルールでSNSトピックを追加
SESの受信ルールにSNSトピックを設定してみました。 [View Active …
-
-
API Gatewayから直接 DynamoDBに書き込む
やりたいこと WebページでOやXを押したときに、どっちを押したかをDynamo …
-
-
JAWS-UG関西IoT専門支部 ✕ SORACOM UG 関西「Wio LTE + 絶対圧センサーで遊ぼう!」ワークショップにいってきた
JAWS-UG関西IoT専門支部 ✕ SORACOM UG 関西「Wio LTE …
-
-
CloudFrontのカスタムヘッダーがなければALBのルーティングで403レスポンスを返す
大阪リージョンにはWAFがまだないです(2021年4月現在) 今のこのブログの構 …
-
-
特定AWSアカウント特定リージョンのCloudFormationスタックを削除するLambda(Python)
やりたいこと 特定アカウント内特定リージョン内のCloudFormationスタ …
-
-
QuickSightのVisualizeをダッシュボード化して定期メール
「Backlogの実績工数をAmazon QuickSightで可視化してわかっ …
-
-
AWS CLIからIAM Identity CenterへサインインしてCodeCommitのリポジトリを使用する
Macで操作しました。 AWS CLIバージョンアップ [crayon-66a4 …
-
-
AWS認定SAPの執筆開始にあたって環境を構築しました
AWS認定ソリューションアーキテクトプロフェッショナル対策本の執筆開始にあたりま …