Logging Amazon Cloud Map API Calls with Amazon CloudTrail
Amazon Cloud Map is integrated with Amazon CloudTrail, a service that provides a record of the actions that are taken by a user, a role, or an Amazon service in Amazon Cloud Map. CloudTrail captures all API calls for most Amazon Cloud Map API actions as events. This includes calls from the Amazon Cloud Map console and all programmatic access, such as the Amazon Cloud Map API and Amazon SDKs. (CloudTrail doesn't capture calls to the Amazon Cloud Map DiscoverInstances API.)
If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon Cloud Map. 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 Cloud Map, the IP address that the request was made from, who made the request, when it was made, and additional details.
Topics
Amazon Cloud Map Information in CloudTrail
CloudTrail is enabled on your Amazon account when you create the account. When activity occurs in Amazon Cloud Map, 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 account. For more information, see Viewing Events with CloudTrail Event History.
For an ongoing record of events in your Amazon account, including events for Amazon Cloud Map, 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 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 topics:
Most Amazon Cloud Map actions are logged by CloudTrail and are documented in the Amazon Cloud Map API Reference. For example, calls to the CreateHttpNamespace, DeleteService, and RegisterInstance actions generate entries in the CloudTrail log files. (CloudTrail doesn't capture calls to the Amazon Cloud Map DiscoverInstances API.)
Every event or log entry contains information about who generated the request. The identity information helps you determine the following situations:
-
Whether the request was made with root or 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.
Viewing Amazon Cloud Map Events in Event History
With CloudTrail, you can view recent events in Event history. To view events for Amazon Cloud Map API requests, you need to choose the Amazon Region where you created your namespaces in the Region selector at the top of the console. If you created namespaces in multiple Amazon Regions, you must view the events for each Region separately. For more information, see Viewing Events with CloudTrail Event History in the Amazon CloudTrail User Guide.
Understanding Amazon Cloud Map 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. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.
The eventName
element identifies the action that occurred. CloudTrail supports all Amazon Cloud Map API
actions. The following example shows a CloudTrail log entry for CreatePublicDnsNamespace.
{ "Records": [ { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "A1B2C3D4E5F6G7EXAMPLE", "arn": "arn:aws:iam::111122223333:user/smithj", "accountId": "111122223333", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "smithj" }, "eventTime": "2018-01-16T00:44:17Z", "eventSource": "servicediscovery.amazonaws.com", "eventName": "CreatePublicDnsNamespace", "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": { "description": "test", "creatorRequestId": "1234567890123456789", "name": "example.com" }, "responseElements": { "operationId": "unmipghn37443trlkgpf4idvvitec6fw-2example" }, "requestID": "35e1872d-c0dc-11e7-99e1-03e9fexample", "eventID": "409b4d91-34e6-41ee-bd97-a816dexample", "eventType": "AwsApiCall", "recipientAccountId": "444455556666" } ] }