Logging Amazon GameLift API calls with Amazon CloudTrail - Amazon GameLift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Logging Amazon GameLift API calls with Amazon CloudTrail

Amazon GameLift is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon service in Amazon GameLift. CloudTrail captures all API calls for Amazon GameLift as events. The calls captured include calls from the Amazon GameLift console and code calls to the Amazon GameLift API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon GameLift. 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 the request that was made to Amazon GameLift, the IP address from which the request was made, who made the request, when it was made, and additional details.

To learn more about CloudTrail, see the Amazon CloudTrail User Guide.

Amazon GameLift information in CloudTrail

CloudTrail is enabled on your Amazon Web Services account when you create the account. When activity occurs in Amazon GameLift, that activity is recorded in a CloudTrail event along with other Amazon service events in Event history. You can view, search, and download recent events in your Amazon Web Services account. For more information, see Viewing events with CloudTrail Event history.

For an ongoing record of events in your Amazon Web Services account, including events for Amazon GameLift, 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 Amazon Web Services Regions. The trail logs events from all Regions in the Amazon partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other Amazon services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following:

All Amazon GameLift actions are logged by CloudTrail and are documented in the Amazon GameLift API Reference. For example, calls to CreateGameSession, CreatePlayerSession and UpdateGameSession actions generate 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 Amazon Identity and Access Management (IAM) user credentials.

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

  • Whether the request was made by another Amazon service.

For more information, see the CloudTrail userIdentity element.

Understanding Amazon GameLift 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 following example shows a CloudTrail log entry that demonstrates the CreateFleet and DescribeFleetAttributes actions.

{ "Records": [ { "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn": "arn:aws-cn:iam::111122223333:user/myUserName", "accountId": "111122223333", "accessKeyId": AKIAIOSFODNN7EXAMPLE", "userName": "myUserName" }, "eventTime": "2015-12-29T23:40:15Z", "eventSource": "gamelift.amazonaws.com", "eventName": "CreateFleet", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "[]", "requestParameters": { "buildId": "build-92b6e8af-37a2-4c10-93bd-4698ea23de8d", "eC2InboundPermissions": [ { "ipRange": "10.24.34.0/23", "fromPort": 1935, "protocol": "TCP", "toPort": 1935 } ], "logPaths": [ "C:\\game\\serverErr.log", "C:\\game\\serverOut.log" ], "eC2InstanceType": "c5.large", "serverLaunchPath": "C:\\game\\MyServer.exe", "description": "Test fleet", "serverLaunchParameters": "-paramX=baz", "name": "My_Test_Server_Fleet" }, "responseElements": { "fleetAttributes": { "fleetId": "fleet-0bb84136-4f69-4bb2-bfec-a9b9a7c3d52e", "serverLaunchPath": "C:\\game\\MyServer.exe", "status": "NEW", "logPaths": [ "C:\\game\\serverErr.log", "C:\\game\\serverOut.log" ], "description": "Test fleet", "serverLaunchParameters": "-paramX=baz", "creationTime": "Dec 29, 2015 11:40:14 PM", "name": "My_Test_Server_Fleet", "buildId": "build-92b6e8af-37a2-4c10-93bd-4698ea23de8d" } }, "requestID": "824a2a4b-ae85-11e5-a8d6-61d5cafb25f2", "eventID": "c8fbea01-fbf9-4c4e-a0fe-ad7dc205ce11", "eventType": "AwsApiCall", "recipientAccountId": "111122223333" }, { "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn": "arn:aws-cn:iam::111122223333:user/myUserName", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "myUserName" }, "eventTime": "2015-12-29T23:40:15Z", "eventSource": "gamelift.amazonaws.com", "eventName": "DescribeFleetAttributes", "awsRegion": "us-west-2", "sourceIPAddress": "192.0.2.0", "userAgent": "[]", "requestParameters": { "fleetIds": [ "fleet-0bb84136-4f69-4bb2-bfec-a9b9a7c3d52e" ] }, "responseElements": null, "requestID": "82e7f0ec-ae85-11e5-a8d6-61d5cafb25f2", "eventID": "11daabcb-0094-49f2-8b3d-3a63c8bad86f", "eventType": "AwsApiCall", "recipientAccountId": "111122223333" }, ] }