CloudTrail によるログ記録
Amazon Redshift、データ共有、Amazon Redshift サーバーレス、Amazon Redshift Data API、クエリエディタ v2 のすべてが AWS CloudTrail と統合されています。CloudTrail は、Amazon Redshift のユーザー、ロール、または AWS サービスによって実行されたアクションを記録するサービスです。CloudTrail のすべての API コールをイベントとして Amazon Redshift にキャプチャします。キャプチャされたコールには、Amazon Redshift コンソールからのコールと、Redshift オペレーションへのコードコールが含まれます。
CloudTrail 証跡を作成する場合は、Amazon S3 バケットに対する CloudTrail イベント (Redshift のイベントなど) の継続的デリバリーを使用できます。証跡を設定しない場合でも、CloudTrail コンソールの [Event history (イベント履歴)] で最新のイベントを表示できます。CloudTrail によって収集されたデータを使用して、多くの情報を判断できます。これには、Redshift に対するリクエスト、リクエスト元の IP アドレス、リクエスト者、リクエスト日時などの詳細を含みます。
CloudTrail は、Amazon Redshift データベース監査ログ作成から独立して、または追加して使用できます。
CloudTrail の詳細については、 AWS CloudTrail ユーザーガイドを参照してください。
CloudTrail での情報
CloudTrail は、アカウント作成時に AWS で有効になります。アクティビティが発生すると、そのアクティビティは、[Event history] (イベント履歴) の他の AWS サービスイベントとともに、CloudTrail イベントに記録されます。最近のイベントは、AWSアカウントで表示、検索、ダウンロードできます。詳細については、「AWS CloudTrail ユーザーガイド」の「CloudTrail イベント履歴でのイベントの表示」を参照してください。
AWS アカウントのイベント (Redshift のイベントなど) を継続的に記録するには、証跡を作成します。CloudTrail は、証跡を使用してログファイルを Amazon S3 バケットに配信します。デフォルトでは、コンソールで証跡を作成すると、すべての AWS リージョンに証跡が適用されます。証跡は、AWSパーティションのすべてのリージョンからのイベントをログに記録し、指定した Amazon S3 バケットにログファイルを配信します。さらに、CloudTrail ログで収集したイベントデータをより詳細に分析し、それに基づいて対応するため、他の AWS サービスを構成できます。詳細については、AWS CloudTrailユーザーガイドで次を参照してください。
Amazon Redshift、Amazon Redshift サーバーレス、Data API、データ共有、クエリエディタ v2 のすべてのアクションは、CloudTrail によってログに記録されます。例えば、AuthorizeDatashare
、CreateNamespace
、ExecuteStatement
、CreateConnection
の各アクションを呼び出すと、CloudTrail ログファイルにエントリが生成されます。
各イベントまたはログエントリには、リクエストの生成者に関する情報が含まれます。ID 情報は次の判断に役立ちます。
-
リクエストが、ルートとユーザー認証情報のどちらを使用して送信されたか。
-
リクエストが、ロールとフェデレーションユーザーの一時的なセキュリティ認証情報のどちらを使用して送信されたか。
-
リクエストが別の AWS サービスによって行われたかどうか。
詳細については、「AWS CloudTrail ユーザーガイド」の「CloudTrail userIdentity Element」を参照してください。
ログファイルエントリ
証跡は、指定した Amazon S3 バケットに対して、イベントをログファイルとして配信できるようにする設定です。CloudTrail のログファイルは、単一か複数のログエントリを含みます。イベント は、任意の出典からの単一のリクエストを表し、リクエストされたアクション、アクションの日時、リクエストパラメータなどに関する情報が含まれます。CloudTrail ログファイルは、パブリック API 呼び出しの順序付けられたスタックトレースではないため、特定の順序では表示されません。
Amazon Redshift データ共有の例
以下の例は、 AuthorizeDataShare
オペレーションを説明する CloudTrail ログエントリを示しています。
{
"eventVersion": "1.08",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AKIAIOSFODNN7EXAMPLE:janedoe",
"arn": "arn:aws:sts::111122223333:user/janedoe",
"accountId": "111122223333",
"accessKeyId": "AKIAI44QH8DHBEXAMPLE",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AKIAIOSFODNN7EXAMPLE:janedoe",
"arn": "arn:aws:sts::111122223333:user/janedoe",
"accountId": "111122223333",
"userName": "janedoe"
},
"attributes": {
"creationDate": "2021-08-02T23:40:45Z",
"mfaAuthenticated": "false"
}
}
},
"eventTime": "2021-08-02T23:40:58Z",
"eventSource": "redshift.amazonaws.com",
"eventName": "AuthorizeDataShare",
"awsRegion": "us-east-1",
"sourceIPAddress": "3.227.36.75",
"userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41",
"requestParameters": {
"dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare",
"consumerIdentifier": "555555555555"
},
"responseElements": {
"dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare",
"producerNamespaceArn": "arn:aws:redshift:us-east-1:123456789012:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53",
"producerArn": "arn:aws:redshift:us-east-1:111122223333:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53",
"allowPubliclyAccessibleConsumers": true,
"dataShareAssociations": [
{
"consumerIdentifier": "555555555555",
"status": "AUTHORIZED",
"createdDate": "Aug 2, 2021 11:40:56 PM",
"statusChangeDate": "Aug 2, 2021 11:40:57 PM"
}
]
},
"requestID": "87ee1c99-9e41-42be-a5c4-00495f928422",
"eventID": "03a3d818-37c8-46a6-aad5-0151803bdb09",
"readOnly": false,
"eventType": "AwsApiCall",
"managementEvent": true,
"recipientAccountId": "111122223333",
"eventCategory": "Management"
}
Amazon Redshift サーバーレスの例
Amazon Redshift サーバーレスは、AWS CloudTrail との統合により、Amazon Redshift サーバーレスで実行されたアクションの記録を提供します。CloudTrail のすべての API コールをイベントとして Amazon Redshift Serverless にキャプチャします。Amazon Redshift サーバーレスの機能の詳細については、「Amazon Redshift サーバーレス機能の概要」を参照してください。
以下の例は、CreateNamespace
アクションを示す CloudTrail ログエントリです。
{
"eventVersion": "1.08",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AAKEOFPINEXAMPLE:admin",
"arn": "arn:aws:sts::111111111111:assumed-role/admin/admin",
"accountId": "111111111111",
"accessKeyId": "AAKEOFPINEXAMPLE",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AAKEOFPINEXAMPLE",
"arn": "arn:aws:iam::111111111111:role/admin",
"accountId": "111111111111",
"userName": "admin"
},
"webIdFederationData": {},
"attributes": {
"creationDate": "2022-03-21T20:51:58Z",
"mfaAuthenticated": "false"
}
}
},
"eventTime": "2022-03-21T23:15:40Z",
"eventSource": "redshift-serverless.amazonaws.com",
"eventName": "CreateNamespace",
"awsRegion": "us-east-1",
"sourceIPAddress": "56.23.155.33",
"userAgent": "aws-cli/2.4.14 Python/3.8.8 Linux/5.4.181-109.354.amzn2int.x86_64 exe/x86_64.amzn.2 prompt/off command/redshift-serverless.create-namespace",
"requestParameters": {
"adminUserPassword": "HIDDEN_DUE_TO_SECURITY_REASONS",
"adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS",
"dbName": "dev",
"namespaceName": "testnamespace"
},
"responseElements": {
"namespace": {
"adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS",
"creationDate": "Mar 21, 2022 11:15:40 PM",
"defaultIamRoleArn": "",
"iamRoles": [],
"logExports": [],
"namespaceArn": "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/befa5123-16c2-4449-afca-1d27cb40fc99",
"namespaceId": "8b726a0c-16ca-4799-acca-1d27cb403599",
"namespaceName": "testnamespace",
"status": "AVAILABLE"
}
},
"requestID": "ed4bb777-8127-4dae-aea3-bac009999163",
"eventID": "1dbee944-f889-4beb-b228-7ad0f312464",
"readOnly": false,
"eventType": "AwsApiCall",
"managementEvent": true,
"recipientAccountId": "111111111111",
"eventCategory": "Management",
}
Amazon Redshift Data API の例
以下の例は、ExecuteStatement
アクションを示す CloudTrail ログエントリです。
{
"eventVersion":"1.05",
"userIdentity":{
"type":"IAMUser",
"principalId":"AKIAIOSFODNN7EXAMPLE:janedoe",
"arn":"arn:aws:sts::123456789012:user/janedoe",
"accountId":"123456789012",
"accessKeyId":"AKIAI44QH8DHBEXAMPLE",
"userName": "janedoe"
},
"eventTime":"2020-08-19T17:55:59Z",
"eventSource":"redshift-data.amazonaws.com",
"eventName":"ExecuteStatement",
"awsRegion":"us-east-1",
"sourceIPAddress":"192.0.2.0",
"userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41",
"requestParameters":{
"clusterIdentifier":"example-cluster-identifier",
"database":"example-database-name",
"dbUser":"example_db_user_name",
"sql":"***OMITTED***"
},
"responseElements":{
"clusterIdentifier":"example-cluster-identifier",
"createdAt":"Aug 19, 2020 5:55:58 PM",
"database":"example-database-name",
"dbUser":"example_db_user_name",
"id":"5c52b37b-9e07-40c1-98de-12ccd1419be7"
},
"requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac",
"eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175",
"readOnly":false,
"eventType":"AwsApiCall",
"recipientAccountId":"123456789012"
}
べき等性に使用される clientToken
を示す ExecuteStatement
アクションを示した CloudTrail ログエントリの例を次に示します。
{
"eventVersion":"1.05",
"userIdentity":{
"type":"IAMUser",
"principalId":"AKIAIOSFODNN7EXAMPLE:janedoe",
"arn":"arn:aws:sts::123456789012:user/janedoe",
"accountId":"123456789012",
"accessKeyId":"AKIAI44QH8DHBEXAMPLE",
"userName": "janedoe"
},
"eventTime":"2020-08-19T17:55:59Z",
"eventSource":"redshift-data.amazonaws.com",
"eventName":"ExecuteStatement",
"awsRegion":"us-east-1",
"sourceIPAddress":"192.0.2.0",
"userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41",
"requestParameters":{
"clusterIdentifier":"example-cluster-identifier",
"database":"example-database-name",
"dbUser":"example_db_user_name",
"sql":"***OMITTED***",
"clientToken":"32db2e10-69ac-4534-b3fc-a191052616ce"
},
"responseElements":{
"clusterIdentifier":"example-cluster-identifier",
"createdAt":"Aug 19, 2020 5:55:58 PM",
"database":"example-database-name",
"dbUser":"example_db_user_name",
"id":"5c52b37b-9e07-40c1-98de-12ccd1419be7"
},
"requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac",
"eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175",
"readOnly":false,
"eventType":"AwsApiCall",
"recipientAccountId":"123456789012"
}
Amazon Redshift クエリエディタ v2 の例
以下の例は、CreateConnection
アクションを示す CloudTrail ログエントリです。
{
"eventVersion": "1.08",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AAKEOFPINEXAMPLE:session",
"arn": "arn:aws:sts::123456789012:assumed-role/MyRole/session",
"accountId": "123456789012",
"accessKeyId": "AKIAI44QH8DHBEXAMPLE",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AAKEOFPINEXAMPLE",
"arn": "arn:aws:iam::123456789012:role/MyRole",
"accountId": "123456789012",
"userName": "MyRole"
},
"webIdFederationData": {},
"attributes": {
"creationDate": "2022-09-21T17:19:02Z",
"mfaAuthenticated": "false"
}
}
},
"eventTime": "2022-09-21T22:22:05Z",
"eventSource": "sqlworkbench.amazonaws.com",
"eventName": "CreateConnection",
"awsRegion": "ca-central-1",
"sourceIPAddress": "192.2.0.2",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0",
"requestParameters": {
"password": "***",
"databaseName": "***",
"isServerless": false,
"name": "***",
"host": "redshift-cluster-2.c8robpbxvbf9.ca-central-1.redshift.amazonaws.com",
"authenticationType": "***",
"clusterId": "redshift-cluster-2",
"username": "***",
"tags": {
"sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session"
}
},
"responseElements": {
"result": true,
"code": "",
"data": {
"id": "arn:aws:sqlworkbench:ca-central-1:123456789012:connection/ce56b1be-dd65-4bfb-8b17-12345123456",
"name": "***",
"authenticationType": "***",
"databaseName": "***",
"secretArn": "arn:aws:secretsmanager:ca-central-1:123456789012:secret:sqlworkbench!7da333b4-9a07-4917-b1dc-12345123456-qTCoFm",
"clusterId": "redshift-cluster-2",
"dbUser": "***",
"userSettings": "***",
"recordDate": "2022-09-21 22:22:05",
"updatedDate": "2022-09-21 22:22:05",
"accountId": "123456789012",
"tags": {
"sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session"
},
"isServerless": false
}
},
"requestID": "9b82f483-9c03-4cdd-bb49-a7009e7da714",
"eventID": "a7cdd442-e92f-46a2-bc82-2325588d41c3",
"readOnly": false,
"eventType": "AwsApiCall",
"managementEvent": true,
"recipientAccountId": "123456789012",
"eventCategory": "Management"
}
AWS CloudTrail ログの Amazon Redshift アカウント ID
Amazon Redshift が別の AWS のサービスを呼び出す際、その呼び出しは、Amazon Redshift に属するアカウント ID で記録されます。自分のアカウント ID では記録されません。たとえば、Amazon Redshift が、クラスターでの暗号化を管理するために CreateGrant
、 Decrypt
、 Encrypt
、 RetireGrant
などの AWS Key Management Service (AWS KMS) オペレーションを呼び出すとします。この場合、この呼び出しは AWS CloudTrail により、Amazon Redshift アカウント ID を使用して記録されます。
Amazon Redshift が他の AWS サービスを呼び出す際、次の表にあるアカウント ID が使用されます。
リージョン | リージョン | アカウント ID |
---|---|---|
米国東部(バージニア州北部) リージョン | us-east-1 | 368064434614 |
米国東部(オハイオ州)リージョン | us-east-2 | 790247189693 |
米国西部 (北カリフォルニア) リージョン | us-west-1 | 703715109447 |
米国西部 (オレゴン州) リージョン | us-west-2 | 473191095985 |
アフリカ(ケープタウン)リージョン | af-south-1 | 420376844563 |
アジアパシフィック (香港) リージョン | ap-east-1 | 651179539253 |
アジアパシフィック (ハイデラバード) リージョン | ap-south-2 | 297058826802 |
アジアパシフィック (ジャカルタ) リージョン | ap-southeast-3 | 623197973179 |
アジアパシフィック (マレーシア) リージョン | ap-southeast-5 | 590184011157 |
アジアパシフィック (メルボルン) リージョン | ap-southeast-4 | 945512339897 |
アジアパシフィック (ムンバイ) リージョン | ap-south-1 | 408097707231 |
アジアパシフィック(大阪)リージョン | ap-northeast-3 | 398671365691 |
アジアパシフィック (ソウル) リージョン | ap-northeast-2 | 713597048934 |
アジアパシフィック (シンガポール) リージョン | ap-southeast-1 | 960118270566 |
アジアパシフィック (シドニー) リージョン | ap-southeast-2 | 485979073181 |
アジアパシフィック (タイ) リージョン | ap-southeast-7 | 767397930036 |
アジアパシフィック (東京) リージョン | ap-northeast-1 | 615915377779 |
カナダ (中部) リージョン | ca-central-1 | 764870610256 |
カナダ西部 (カルガリー) | ca-west-1 | 830903446466 |
欧州(フランクフルト)リージョン | eu-central-1 | 434091160558 |
欧州(アイルランド)リージョン | eu-west-1 | 246478207311 |
欧州(ロンドン)リージョン | eu-west-2 | 885798887673 |
欧州(ミラノ)リージョン | eu-south-1 | 041313461515 |
欧州(パリ)リージョン | eu-west-3 | 694668203235 |
欧州 (スペイン) リージョン | eu-south-2 | 028811157404 |
欧州(ストックホルム)リージョン | eu-north-1 | 553461782468 |
欧州 (チューリッヒ) リージョン | eu-central-2 | 668912161003 |
イスラエル (テルアビブ) リージョン | il-central-1 | 901883065212 |
メキシコ (中部) リージョン | mx-central-1 | 058264411980 |
中東 (バーレーン) リージョン | me-south-1 | 051362938876 |
中東 (アラブ首長国連邦) リージョン | me-central-1 | 595013617770 |
南米 (サンパウロ) リージョン | sa-east-1 | 392442076723 |
次の例は、Amazon Redshift から呼び出された AWS KMS Decrypt オペレーションの CloudTrail ログエントリを示しています。
{ "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AROAI5QPCMKLTL4VHFCYY:i-0f53e22dbe5df8a89", "arn": "arn:aws:sts::790247189693:assumed-role/prod-23264-role-wp/i-0f53e22dbe5df8a89", "accountId": "790247189693", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2017-03-03T16:24:54Z" }, "sessionIssuer": { "type": "Role", "principalId": "AROAI5QPCMKLTL4VHFCYY", "arn": "arn:aws:iam::790247189693:role/prod-23264-role-wp", "accountId": "790247189693", "userName": "prod-23264-role-wp" } } }, "eventTime": "2017-03-03T17:16:51Z", "eventSource": "kms.amazonaws.com", "eventName": "Decrypt", "awsRegion": "us-east-2", "sourceIPAddress": "52.14.143.61", "userAgent": "aws-internal/3", "requestParameters": { "encryptionContext": { "aws:redshift:createtime": "20170303T1710Z", "aws:redshift:arn": "arn:aws:redshift:us-east-2:123456789012:cluster:my-dw-instance-2" } }, "responseElements": null, "requestID": "30d2fe51-0035-11e7-ab67-17595a8411c8", "eventID": "619bad54-1764-4de4-a786-8898b0a7f40c", "readOnly": true, "resources": [ { "ARN": "arn:aws:kms:us-east-2:123456789012:key/f8f4f94f-e588-4254-b7e8-078b99270be7", "accountId": "123456789012", "type": "AWS::KMS::Key" } ], "eventType": "AwsApiCall", "recipientAccountId": "123456789012", "sharedEventID": "c1daefea-a5c2-4fab-b6f4-d8eaa1e522dc" }