はじめに
IAM Identity Center (旧 AWS SSO) を利用して複数の AWS アカウントに対するシングルサインオン機能を提供できます。IAM Identity Center のシングルサインオン環境を運用していくうえで、「誰が」「いつ」「ログインが成功したのか」「どの AWS アカウントにアクセスしたか」というようなログを知りたくなるときがあります。ユースケースとしては、社内の監査だったり、アクセスログの確認などです。
IAM Identity Center を使ったログインは、CloudTrail にログが出力されます。今回は、どんなログが出力されるか見てみましょう。
より詳細で網羅的な情報を知りたい方は、次の AWS Document も一緒に確認してみてください。
Identity Center を使ったログイン
まず、CloudTrail 上のログを生み出すために、Identity Center を使ってログインをします。ユーザー名を指定します。
パスワードを指定します。
Identity Center のアクセスポータルが開かれました。この記事の環境はいろいろ連携しているんですが、管理している 他 AWS アカウントの Management Console を開きます。
別 AWS アカウントのコンソールが開けました。
親側 : CloudTrail
Identity Center を管理している側の AWS Account の CloudTrail を確認します。
Event history を開き、Event name
が UserAuthentication
のものを検索します。UserAuthentication
は、Identity Center として正常に認証が完了したことを示すイベントです。
クリックすると詳細な JSON ログを確認できます。次のようなログとなっています。
- userName : どのユーザーを使ったログインなのか
- sourceIPAddress : 操作元の IP アドレス
- このログでは、どの 子供 AWS アカウントにアクセスしたのかはわからない
{
"eventVersion": "1.08",
"userIdentity": {
"type": "Unknown",
"principalId": "sampleaccountid1",
"arn": "",
"accountId": "sampleaccountid1",
"accessKeyId": "",
"userName": "ssouser01"
},
"eventTime": "2023-03-29T12:55:53Z",
"eventSource": "signin.amazonaws.com",
"eventName": "UserAuthentication",
"awsRegion": "ap-northeast-1",
"sourceIPAddress": "1.1.1.1",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
"requestParameters": null,
"responseElements": null,
"additionalEventData": {
"AuthWorkflowID": "e92f6047-a95d-468f-b0b2-ba63da94161e",
"LoginTo": "https://masked.awsapps.com/start/",
"CredentialType": "PASSWORD"
},
"requestID": "7fbb0736-5394-4a0d-a4f6-7ce2fdc56038",
"eventID": "84aafc81-fd91-464b-8624-03bb4b45ef39",
"readOnly": false,
"eventType": "AwsServiceEvent",
"managementEvent": true,
"recipientAccountId": "sampleaccountid1",
"serviceEventDetails": {
"UserAuthentication": "Success"
},
"eventCategory": "Management"
}
どの子供 AWS アカウントにログインしたのかを示すログがこちらです。Event source sso.amazonaws.com
で検索して、Federate
を見つけると良いでしょう。
詳細はこのようなログになっています。
- UserAuthentication.account_id : 子供の AWS アカウントの ID がわかる
- UserAuthentication.role_name : Identity Center 上の、どの権限セットを利用したかわかる
{
"eventVersion": "1.08",
"userIdentity": {
"type": "Unknown",
"principalId": "95671c316d-7a6a2ff4-4eb0-414a-9447-a1decc0c7c1e",
"accountId": "sampleaccountid1",
"userName": "ssouser01"
},
"eventTime": "2023-03-29T12:56:43Z",
"eventSource": "sso.amazonaws.com",
"eventName": "Federate",
"awsRegion": "ap-northeast-1",
"sourceIPAddress": "1.1.1.1",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
"requestParameters": null,
"responseElements": null,
"requestID": "6712e76a-fa40-41b9-82c5-6e34c0647f38",
"eventID": "5cb8dfd3-a781-44a2-880e-83423ae040ce",
"readOnly": false,
"eventType": "AwsServiceEvent",
"managementEvent": true,
"recipientAccountId": "sampleaccountid1",
"serviceEventDetails": {
"role_name": "AdministratorAccess",
"account_id": "sampleaccountid2"
},
"eventCategory": "Management"
}
子側 : CloudTrail
親側の CloudTrail でもだいぶ情報が取れますが、子供の AWS アカウント側でも CloudTrail を見てみましょう。
AWS Management Console のログインは、ConcoleLogin
で検索するとわかります。
詳細な JSON ログです。
{
"eventVersion": "1.08",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROA5WQZQQJKC3BYISIHSKAIYB:ssouser01",
"arn": "arn:aws:sts::sampleaccountid2:assumed-role/AWSReservedSSO_AdministratorAccess_5422dd0faed3c601/ssouser01",
"accountId": "sampleaccountid2",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AROA5WQZQQJKC3BYISIHSKAIYB",
"arn": "arn:aws:iam::sampleaccountid2:role/aws-reserved/sso.amazonaws.com/ap-northeast-1/AWSReservedSSO_AdministratorAccess_5422dd0faed3c601",
"accountId": "sampleaccountid2",
"userName": "AWSReservedSSO_AdministratorAccess_5422dd0faed3c601"
},
"webIdFederationData": {},
"attributes": {
"creationDate": "2023-03-29T12:56:43Z",
"mfaAuthenticated": "false"
}
}
},
"eventTime": "2023-03-29T12:56:44Z",
"eventSource": "signin.amazonaws.com",
"eventName": "ConsoleLogin",
"awsRegion": "ap-northeast-1",
"sourceIPAddress": "1.1.1.1",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
"requestParameters": null,
"responseElements": {
"ConsoleLogin": "Success"
},
"additionalEventData": {
"MobileVersion": "No",
"MFAUsed": "No"
},
"eventID": "60c1d7fa-615c-4c70-bb83-6b44b39941c7",
"readOnly": false,
"eventType": "AwsConsoleSignIn",
"managementEvent": true,
"recipientAccountId": "sampleaccountid2",
"eventCategory": "Management",
"tlsDetails": {
"tlsVersion": "TLSv1.2",
"cipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
"clientProvidedHostHeader": "ap-northeast-1.signin.aws.amazon.com"
}
}
参考 URL