使用 Amazon CloudTrail 记录 Amazon Route 53 API 调用
Route 53 与 Amazon CloudTrail 集成,后者是一项服务,提供 Route 53 中由用户、角色或 Amazon 服务所采取操作的记录。CloudTrail 将对 Route 53 的所有 API 调用均作为事件捕获,包括来自 Route 53 控制台的调用和对 Route 53 API 的代码调用。如果您创建跟踪,则可以使 CloudTrail 事件持续传送到 Amazon S3 存储桶(包括 Route 53 的事件)。如果您不配置跟踪,则仍可在 CloudTrail 控制台中的 Event history(事件历史记录) 中查看最新事件。使用 CloudTrail 收集的信息,您可以确定向 Route 53 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间以及其它详细信息。
CloudTrail 中的 Route 53 信息
在您创建 Amazon 账户时,将在该账户上启用 CloudTrail。当 Route 53 中发生活动时,该活动将记录在 CloudTrail 事件中,并与其它 Amazon 服务事件一同保存在 Event history(事件历史记录)中。您可以在 Amazon 账户中查看、搜索和下载最新事件。有关更多信息,请参阅使用 CloudTrail 事件历史记录查看事件。
要持续记录 Amazon 账户中的事件(包括 Route 53 的事件),请创建跟踪记录。通过跟踪,CloudTrail 可将日志文件传送至 Amazon S3 桶。默认情况下,在控制台中创建跟踪记录时,此跟踪记录应用于所有 区域。此跟踪记录在 Amazon 分区中记录所有区域中的事件,并将日志文件传送至您指定的 Simple Storage Service(Amazon S3)存储桶。此外,您可以配置其他Amazon服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取行动。有关更多信息,请参阅:
CloudTrail 记录所有 Route 53 操作,这些操作均存储在了 Amazon Route 53 API 参考中。例如,对 CreateHostedZone
、CreateHealthCheck
和 RegisterDomain
操作的调用会在 CloudTrail 日志文件中生成条目。
每个事件或日志条目都包含有关生成请求的人员信息。身份信息可帮助您确定以下内容:
-
请求是使用根用户凭证还是 IAM 用户凭证发出的。
-
请求是使用角色还是联合身份用户的临时安全凭证发出的。
-
请求是否由其它 Amazon 服务发出。
有关更多信息,请参阅 CloudTrail userIdentity 元素。
在事件历史记录中查看 Route 53 事件
CloudTrail 可让您在 Event history(事件历史记录)中查看最新事件。要查看 Route 53 API 请求的事件,您必须在控制台顶部的区域选择器中选择美国东部(弗吉尼亚北部)。有关更多信息,请参阅 Amazon CloudTrail 用户指南中的使用 CloudTrail 事件历史记录查看事件。
了解 Route 53 日志文件条目
跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 Amazon S3 桶。CloudTrail 日志文件包含一个或多个日志条目。一个事件表示来自任何源的一个请求,包括有关请求的操作、操作的日期和时间、请求参数等方面的信息。CloudTrail 日志文件不是公用 API 调用的有序堆栈跟踪,因此它们不会按任何特定顺序显示。
eventName
元素可标识发生的操作。(在 CloudTrail 日志中,第一个字母对于域注册操作为小写形式,即使它在此类操作的名称中是大写形式。例如,UpdateDomainContact
在日志中显示为 updateDomainContact
。) CloudTrail 支持所有 Route 53 API 操作。下面的示例显示了一个 CloudTrail 日志条目,该条目说明了以下操作。
列出与 Amazon 账户关联的托管区域
创建运行状况检查
创建两个记录
删除托管区域
为已注册的域更新信息
创建 Route 53 Resolver 出站端点
{ "Records": [ { "apiVersion": "2013-04-01", "awsRegion": "us-east-1", "eventID": "1cdbea14-e162-43bb-8853-f9f86d4739ca", "eventName": "ListHostedZones", "eventSource": "route53.amazonaws.com", "eventTime": "2015-01-16T00:41:48Z", "eventType": "AwsApiCall", "eventVersion": "1.02", "recipientAccountId": "444455556666", "requestID": "741e0df7-9d18-11e4-b752-f9c6311f3510", "requestParameters": null, "responseElements": null, "sourceIPAddress": "192.0.2.92", "userAgent": "Apache-HttpClient/4.3 (java 1.5)", "userIdentity": { "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "accountId": "111122223333", "arn": "arn:aws:iam::111122223333:user/smithj", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "type": "IAMUser", "userName": "smithj" } }, { "apiVersion": "2013-04-01", "awsRegion": "us-east-1", "eventID": "45ec906a-1325-4f61-b133-3ef1012b0cbc", "eventName": "CreateHealthCheck", "eventSource": "route53.amazonaws.com", "eventTime": "2018-01-16T00:41:57Z", "eventType": "AwsApiCall", "eventVersion": "1.02", "recipientAccountId": "444455556666", "requestID": "79915168-9d18-11e4-b752-f9c6311f3510", "requestParameters": { "callerReference": "2014-05-06 64832", "healthCheckConfig": { "iPAddress": "192.0.2.249", "port": 80, "type": "TCP" } }, "responseElements": { "healthCheck": { "callerReference": "2014-05-06 64847", "healthCheckConfig": { "failureThreshold": 3, "iPAddress": "192.0.2.249", "port": 80, "requestInterval": 30, "type": "TCP" }, "healthCheckVersion": 1, "id": "b3c9cbc6-cd18-43bc-93f8-9e557example" }, "location": "https://route53.amazonaws.com/2013-04-01/healthcheck/b3c9cbc6-cd18-43bc-93f8-9e557example" }, "sourceIPAddress": "192.0.2.92", "userAgent": "Apache-HttpClient/4.3 (java 1.5)", "userIdentity": { "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "accountId": "111122223333", "arn": "arn:aws:iam::111122223333:user/smithj", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "type": "IAMUser", "userName": "smithj" } }, { "additionalEventData": { "Note": "Do not use to reconstruct hosted zone" }, "apiVersion": "2013-04-01", "awsRegion": "us-east-1", "eventID": "883b14d9-2f84-4005-8bc5-c7bf0cebc116", "eventName": "ChangeResourceRecordSets", "eventSource": "route53.amazonaws.com", "eventTime": "2018-01-16T00:41:43Z", "eventType": "AwsApiCall", "eventVersion": "1.02", "recipientAccountId": "444455556666", "requestID": "7081d4c6-9d18-11e4-b752-f9c6311f3510", "requestParameters": { "changeBatch": { "changes": [ { "action": "CREATE", "resourceRecordSet": { "name": "prod.example.com.", "resourceRecords": [ { "value": "192.0.1.1" }, { "value": "192.0.1.2" }, { "value": "192.0.1.3" }, { "value": "192.0.1.4" } ], "tTL": 300, "type": "A" } }, { "action": "CREATE", "resourceRecordSet": { "name": "test.example.com.", "resourceRecords": [ { "value": "192.0.1.1" }, { "value": "192.0.1.2" }, { "value": "192.0.1.3" }, { "value": "192.0.1.4" } ], "tTL": 300, "type": "A" } } ], "comment": "Adding subdomains" }, "hostedZoneId": "Z1PA6795UKMFR9" }, "responseElements": { "changeInfo": { "comment": "Adding subdomains", "id": "/change/C156SRE0X2ZB10", "status": "PENDING", "submittedAt": "Jan 16, 2018 12:41:43 AM" } }, "sourceIPAddress": "192.0.2.92", "userAgent": "Apache-HttpClient/4.3 (java 1.5)", "userIdentity": { "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "accountId": "111122223333", "arn": "arn:aws:iam::111122223333:user/smithj", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "type": "IAMUser", "userName": "smithj" } }, { "apiVersion": "2013-04-01", "awsRegion": "us-east-1", "eventID": "0cb87544-ebee-40a9-9812-e9dda1962cb2", "eventName": "DeleteHostedZone", "eventSource": "route53.amazonaws.com", "eventTime": "2018-01-16T00:41:37Z", "eventType": "AwsApiCall", "eventVersion": "1.02", "recipientAccountId": "444455556666", "requestID": "6d5d149f-9d18-11e4-b752-f9c6311f3510", "requestParameters": { "id": "Z1PA6795UKMFR9" }, "responseElements": { "changeInfo": { "id": "/change/C1SIJYUYIKVJWP", "status": "PENDING", "submittedAt": "Jan 16, 2018 12:41:36 AM" } }, "sourceIPAddress": "192.0.2.92", "userAgent": "Apache-HttpClient/4.3 (java 1.5)", "userIdentity": { "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "accountId": "111122223333", "arn": "arn:aws:iam::111122223333:user/smithj", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "type": "IAMUser", "userName": "smithj" } }, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/smithj", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "smithj", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2018-11-01T19:43:59Z" } }, "invokedBy": "test" }, "eventTime": "2018-11-01T19:49:36Z", "eventSource": "route53domains.amazonaws.com", "eventName": "updateDomainContact", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.92", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0", "requestParameters": { "domainName": { "name": "example.com" } }, "responseElements": { "requestId": "034e222b-a3d5-4bec-8ff9-35877ff02187" }, "additionalEventData": "Personally-identifying contact information is not logged in the request", "requestID": "015b7313-bf3d-11e7-af12-cf75409087f6", "eventID": "f34f3338-aaf4-446f-bf0e-f72323bac94d", "eventType": "AwsApiCall", "recipientAccountId": "444455556666" }, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/smithj", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2018-11-01T14:33:09Z" }, "sessionIssuer": { "type": "Role", "principalId": "AROAIUZEZLWWZOEXAMPLE", "arn": "arn:aws:iam::123456789012:role/Admin", "accountId": "123456789012", "userName": "Admin" } } }, "eventTime": "2018-11-01T14:37:19Z", "eventSource": "route53resolver.amazonaws.com", "eventName": "CreateResolverEndpoint", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.176", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0", "requestParameters": { "creatorRequestId": "123456789012", "name": "OutboundEndpointDemo", "securityGroupIds": [ "sg-05618b249example" ], "direction": "OUTBOUND", "ipAddresses": [ { "subnetId": "subnet-01cb0c4676example" }, { "subnetId": "subnet-0534819b32example" } ], "tags": [] }, "responseElements": { "resolverEndpoint": { "id": "rslvr-out-1f4031f1f5example", "creatorRequestId": "123456789012", "arn": "arn:aws:route53resolver:us-west-2:123456789012:resolver-endpoint/rslvr-out-1f4031f1f5example", "name": "OutboundEndpointDemo", "securityGroupIds": [ "sg-05618b249example" ], "direction": "OUTBOUND", "ipAddressCount": 2, "hostVPCId": "vpc-0de29124example", "status": "CREATING", "statusMessage": "[Trace id: 1-5bd1d51e-f2f3032eb75649f71example] Creating the Resolver Endpoint", "creationTime": "2018-11-01T14:37:19.045Z", "modificationTime": "2018-11-01T14:37:19.045Z" } }, "requestID": "3f066d98-773f-4628-9cba-4ba6eexample", "eventID": "cb05b4f9-9411-4507-813b-33cb0example", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" } ] }