Logging AWS Cloud Map API Calls with AWS CloudTrail - AWS Cloud Map

Logging AWS Cloud Map API Calls with AWS CloudTrail

AWS Cloud Map is integrated with AWS CloudTrail, a service that provides a record of the actions that are taken by a user, a role, or an AWS service in AWS Cloud Map. CloudTrail captures all API calls for most AWS Cloud Map API actions as events. This includes calls from the AWS Cloud Map console and all programmatic access, such as the AWS Cloud Map API and AWS SDKs. (CloudTrail doesn't capture calls to the AWS 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 AWS 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 AWS Cloud Map, the IP address that the request was made from, who made the request, when it was made, and additional details.

AWS Cloud Map Information in CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in AWS Cloud Map, 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 AWS 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 AWS 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 topics:

Most AWS Cloud Map actions are logged by CloudTrail and are documented in the AWS 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 AWS 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 AWS service.

For more information, see the CloudTrail userIdentity Element.

Viewing AWS Cloud Map Events in Event History

With CloudTrail, you can view recent events in Event history. To view events for AWS Cloud Map API requests, you need to choose the AWS Region where you created your namespaces in the Region selector at the top of the console. If you created namespaces in multiple AWS Regions, you must view the events for each Region separately. For more information, see Viewing Events with CloudTrail Event History in the AWS CloudTrail User Guide.

Understanding AWS 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 AWS 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" } ] }