Logging MemoryDB for Redis API calls with Amazon CloudTrail - Amazon MemoryDB for Redis
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.

Logging MemoryDB for Redis API calls with Amazon CloudTrail

MemoryDB for Redis is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon service in MemoryDB for Redis. CloudTrail captures all API calls for MemoryDB for Redis as events, including calls from the MemoryDB for Redis console and from code calls to the MemoryDB for Redis API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for MemoryDB for Redis. 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 MemoryDB for Redis, 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.

MemoryDB for Redis information in CloudTrail

CloudTrail is enabled on your Amazon account when you create the account. When activity occurs in MemoryDB for Redis, 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 MemoryDB for Redis, 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 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 MemoryDB for Redis actions are logged by CloudTrail. For example, calls to the CreateCluster, DescribeClusters and UpdateCluster 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 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 MemoryDB for Redis 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 are not an ordered stack trace of the public API calls, so they do not appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the CreateCluster action.

{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "EKIAUAXQT3SWDEXAMPLE", "arn": "arn:aws:iam::123456789012:user/john", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "john" }, "eventTime": "2021-07-10T17:56:46Z", "eventSource": "memorydb.amazonaws.com", "eventName": "CreateCluster", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.01", "userAgent": "aws-cli/2.2.29 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off command/memorydb.create-cluster", "requestParameters": { "clusterName": "memorydb-cluster", "nodeType": "db.r6g.large", "subnetGroupName": "memorydb-subnet-group", "aCLName": "open-access" }, "responseElements": { "cluster": { "name": "memorydb-cluster", "status": "creating", "numberOfShards": 1, "availabilityMode": "MultiAZ", "clusterEndpoint": { "port": 6379 }, "nodeType": "db.r6g.large", "engineVersion": "6.2", "enginePatchVersion": "6.2.6", "parameterGroupName": "default.memorydb-redis6", "parameterGroupStatus": "in-sync", "subnetGroupName": "memorydb-subnet-group", "tLSEnabled": true, "aRN": "arn:aws:memorydb:us-east-1:123456789012:cluster/memorydb-cluster", "snapshotRetentionLimit": 0, "maintenanceWindow": "tue:06:30-tue:07:30", "snapshotWindow": "09:00-10:00", "aCLName": "open-access", "dataTiering": "false", "autoMinorVersionUpgrade": true } }, "requestID": "506fc951-9ae2-42bb-872c-98028dc8ed11", "eventID": "2ecf3dc3-c931-4df0-a2b3-be90b596697e", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }

The following example shows a CloudTrail log entry that demonstrates the DescribeClusters action. Note that for all MemoryDB for Redis Describe and List calls (Describe* and List*), the responseElements section is removed and appears as null.

{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "EKIAUAXQT3SWDEXAMPLE", "arn": "arn:aws:iam::123456789012:user/john", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "john" }, "eventTime": "2021-07-10T18:39:51Z", "eventSource": "memorydb.amazonaws.com", "eventName": "DescribeClusters", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.01", "userAgent": "aws-cli/2.2.29 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off command/memorydb.describe-clusters", "requestParameters": { "maxResults": 50, "showShardDetails": true }, "responseElements": null, "requestID": "5e831993-52bb-494d-9bba-338a117c2389", "eventID": "32a3dc0a-31c8-4218-b889-1a6310b7dd50", "readOnly": true, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }

The following example shows a CloudTrail log entry that records an UpdateCluster action.

{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "EKIAUAXQT3SWDEXAMPLE", "arn": "arn:aws:iam::123456789012:user/john", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "john" }, "eventTime": "2021-07-10T19:23:20Z", "eventSource": "memorydb.amazonaws.com", "eventName": "UpdateCluster", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.01", "userAgent": "aws-cli/2.2.29 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off command/memorydb.update-cluster", "requestParameters": { "clusterName": "memorydb-cluster", "snapshotWindow": "04:00-05:00", "shardConfiguration": { "shardCount": 2 } }, "responseElements": { "cluster": { "name": "memorydb-cluster", "status": "updating", "numberOfShards": 2, "availabilityMode": "MultiAZ", "clusterEndpoint": { "address": "clustercfg.memorydb-cluster.cde8da.memorydb.us-east-1.amazonaws.com", "port": 6379 }, "nodeType": "db.r6g.large", "engineVersion": "6.2", "EnginePatchVersion": "6.2.6", "parameterGroupName": "default.memorydb-redis6", "parameterGroupStatus": "in-sync", "subnetGroupName": "memorydb-subnet-group", "tLSEnabled": true, "aRN": "arn:aws:memorydb:us-east-1:123456789012:cluster/memorydb-cluster", "snapshotRetentionLimit": 0, "maintenanceWindow": "tue:06:30-tue:07:30", "snapshotWindow": "04:00-05:00", "autoMinorVersionUpgrade": true, "DataTiering": "false" } }, "requestID": "dad021ce-d161-4365-8085-574133afab54", "eventID": "e0120f85-ab7e-4ad4-ae78-43ba15dee3d8", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }

The following example shows a CloudTrail log entry that demonstrates the CreateUser action. Note that for MemoryDB for Redis calls that contain sensitive data, that data will be redacted in the corresponding CloudTrail event as shown in the requestParameters section below.

{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "EKIAUAXQT3SWDEXAMPLE", "arn": "arn:aws:iam::123456789012:user/john", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "john" }, "eventTime": "2021-07-10T19:56:13Z", "eventSource": "memorydb.amazonaws.com", "eventName": "CreateUser", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.01", "userAgent": "aws-cli/2.2.29 Python/3.9.6 Darwin/19.6.0 source/x86_64 prompt/off command/memorydb.create-user", "requestParameters": { "userName": "memorydb-user", "authenticationMode": { "type": "password", "passwords": [ "HIDDEN_DUE_TO_SECURITY_REASONS" ] }, "accessString": "~* &* -@all +@read" }, "responseElements": { "user": { "name": "memorydb-user", "status": "active", "accessString": "off ~* &* -@all +@read", "aCLNames": [], "minimumEngineVersion": "6.2", "authentication": { "type": "password", "passwordCount": 1 }, "aRN": "arn:aws:memorydb:us-east-1:123456789012:user/memorydb-user" } }, "requestID": "ae288b5e-80ab-4ff8-989a-5ee5c67cd193", "eventID": "ed096e3e-16f1-4a23-866c-0baa6ec769f6", "readOnly": false, "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "123456789012", "eventCategory": "Management" }