Logging API calls for your transit gateway using AWS CloudTrail - Amazon VPC

Logging API calls for your transit gateway using AWS CloudTrail

AWS CloudTrail is a service that provides a record of actions taken by a user, role, or an AWS service. CloudTrail captures all transit gateway API calls as events. The calls captured include calls from the AWS Management Console and code calls to the transit gateway API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for transit gateways. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine what request was made to the transit gateway API, the IP address from which the request was made, who made the request, when it was made, and additional details.

For more information about transit gateway APIs, see AWS Transit Gateway actions in the Amazon EC2 API Reference.

For more information about CloudTrail, see the AWS CloudTrail User Guide.

Transit gateway information in CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs through the transit gateway API, that activity is recorded in a CloudTrail event along with other AWS service events in Event history. You can view, search, and download recent events in your AWS account. For more information, see Viewing Events with CloudTrail Event History.

For an ongoing record of events in your AWS account, including events for the transit gateway API, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all Regions. The trail logs events from all Regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following:

All calls to transit gateway actions are logged by CloudTrail. For example, calls to the CreateTransitGateway action generates entries in the CloudTrail log files.

Every event or log entry contains information about who generated the request. The identity information helps you determine the following:

  • Whether the request was made with root or AWS Identity and Access Management user credentials.

  • Whether the request was made with temporary security credentials for a role or federated user.

  • Whether the request was made by another AWS service.

For more information, see the CloudTrail userIdentity Element.

Understanding transit gateway log file entries

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The log files include events for all API calls for your AWS account, not just transit gateway API calls. You can locate calls to the transit gateway API by checking for eventSource elements with the value ec2.amazonaws.com. To view a record for a specific action, such as CreateTransitGateway, check for eventName elements with the action name.

The following are example CloudTrail log records for the transit gateway API for a user who created a transit gateway using the console. You can identify the console using the userAgent element. You can identify the requested API call using the eventName elements. Information about the user (Alice) can be found in the userIdentity element.

Example: CreateTransitGateway
{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "Alice" }, "eventTime": "2018-11-15T05:25:50Z", "eventSource": "ec2.amazonaws.com", "eventName": "CreateTransitGateway", "awsRegion": "us-west-2", "sourceIPAddress": "", "userAgent": "console.ec2.amazonaws.com", "requestParameters": { "CreateTransitGatewayRequest": { "Options": { "DefaultRouteTablePropagation": "enable", "AutoAcceptSharedAttachments": "disable", "DefaultRouteTableAssociation": "enable", "VpnEcmpSupport": "enable", "DnsSupport": "enable" }, "TagSpecification": { "ResourceType": "transit-gateway", "tag": 1, "Tag": { "Value": "my-tgw", "tag": 1, "Key": "Name" } } } }, "responseElements": { "CreateTransitGatewayResponse": { "xmlns": "http://ec2.amazonaws.com/doc/2016-11-15/", "requestId": "a07c1edf-c201-4e44-bffb-3ce90EXAMPLE", "transitGateway": { "tagSet": { "item": { "value": "my-tgw", "key": "Name" } }, "creationTime": "2018-11-15T05:25:50.000Z", "transitGatewayId": "tgw-0a13743bd6c1f5fcb", "options": { "propagationDefaultRouteTableId": "tgw-rtb-0123cd602be10b00a", "amazonSideAsn": 64512, "defaultRouteTablePropagation": "enable", "vpnEcmpSupport": "enable", "autoAcceptSharedAttachments": "disable", "defaultRouteTableAssociation": "enable", "dnsSupport": "enable", "associationDefaultRouteTableId": "tgw-rtb-0123cd602be10b00a" }, "state": "pending", "ownerId": 123456789012 } } }, "requestID": "a07c1edf-c201-4e44-bffb-3ce90EXAMPLE", "eventID": "e8fa575f-4964-4ab9-8ca4-6b5b4EXAMPLE", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }