Log Amazon VPC Transit Gateways API calls using Amazon CloudTrail
Amazon VPC Transit Gateways is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon Web Services service. CloudTrail captures all API calls for Transit Gateway as events. The calls captured include calls from the Transit Gateway console and code calls to the Transit Gateway API operations. Using the information collected by CloudTrail, you can determine the request that was made to Transit Gateway, the IP address from which the request was made, when it was made, and additional details.
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 user or user credentials.
-
Whether the request was made on behalf of an IAM Identity Center user.
-
Whether the request was made with temporary security credentials for a role or federated user.
-
Whether the request was made by another Amazon Web Services service.
CloudTrail is active in your Amazon Web Services account when you create the account and you automatically have access to the CloudTrail Event history. The CloudTrail Event history provides a viewable, searchable, downloadable, and immutable record of the past 90 days of recorded management events in an Amazon Web Services Region. For more information, see Working with CloudTrail Event history in the Amazon CloudTrail User Guide. There are no CloudTrail charges for viewing the Event history.
For an ongoing record of events in your Amazon Web Services account past 90 days, create a trail or a CloudTrail Lake event data store.
- CloudTrail trails
-
A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. All trails created using the Amazon Web Services Management Console are multi-Region. You can create a single-Region or a multi-Region trail by using the Amazon CLI. Creating a multi-Region trail is recommended because you capture activity in all Amazon Web Services Regions in your account. If you create a single-Region trail, you can view only the events logged in the trail's Amazon Web Services Region. For more information about trails, see Creating a trail for your Amazon Web Services account and Creating a trail for an organization in the Amazon CloudTrail User Guide.
You can deliver one copy of your ongoing management events to your Amazon S3 bucket at no charge from CloudTrail by creating a trail, however, there are Amazon S3 storage charges. For more information about CloudTrail pricing, see Amazon CloudTrail Pricing
. For information about Amazon S3 pricing, see Amazon S3 Pricing . - CloudTrail Lake event data stores
-
CloudTrail Lake lets you run SQL-based queries on your events. CloudTrail Lake converts existing events in row-based JSON format to Apache ORC
format. ORC is a columnar storage format that is optimized for fast retrieval of data. Events are aggregated into event data stores, which are immutable collections of events based on criteria that you select by applying advanced event selectors. The selectors that you apply to an event data store control which events persist and are available for you to query. For more information about CloudTrail Lake, see Working with Amazon CloudTrail Lake in the Amazon CloudTrail User Guide. CloudTrail Lake event data stores and queries incur costs. When you create an event data store, you choose the pricing option you want to use for the event data store. The pricing option determines the cost for ingesting and storing events, and the default and maximum retention period for the event data store. For more information about CloudTrail pricing, see Amazon CloudTrail Pricing
.
Transit Gateway management events
Management events provide information about management operations that are performed on resources in your Amazon Web Services account. These are also known as control plane operations. By default, CloudTrail logs management events.
Amazon VPC Transit Gateways logs all Transit Gateway control plane operations as management events. For a list of the Amazon VPC Transit Gateways control plane operations that Transit Gateway logs to CloudTrail, see the Amazon VPC Transit Gateways API Reference.
Transit Gateway event examples
An event represents a single request from any source and includes information about the requested API operation, the date and time of the operation, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so events don't appear in any specific order.
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 Amazon 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 is an example CloudTrail log record 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-cn: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": "198.51.100.1",
"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"
}