Monitoring Amazon RDS API calls in AWS CloudTrail - Amazon Relational Database Service

Monitoring Amazon RDS API calls in AWS CloudTrail

AWS CloudTrail is an AWS service that helps you audit your AWS account. AWS CloudTrail is turned on for your AWS account when you create it. For more information about CloudTrail, see the AWS CloudTrail User Guide.

CloudTrail integration with Amazon RDS

All Amazon RDS actions are logged by CloudTrail. CloudTrail provides a record of actions taken by a user, role, or an AWS service in Amazon RDS.

CloudTrail events

CloudTrail captures API calls for Amazon RDS as events. 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. Events include calls from the Amazon RDS console and from code calls to the Amazon RDS API operations.

Amazon RDS activity is recorded in a CloudTrail event in Event history. You can use the CloudTrail console to view the last 90 days of recorded API activity and events in an AWS Region. For more information, see Viewing events with CloudTrail event history.

CloudTrail trails

For an ongoing record of events in your AWS account, including events for Amazon RDS, create a trail. A trail is a configuration that enables delivery of events to a specified Amazon S3 bucket. CloudTrail typically delivers log files within 15 minutes of account activity.

Note

If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history.

You can create two types of trails for an AWS account: a trail that applies to all Regions, or a trail that applies to one Region. By default, when you create a trail in the console, the trail applies to all Regions.

Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see:

Amazon RDS log file entries

CloudTrail log files contain one or more log entries. 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 CreateDBInstance action.

{ "eventVersion": "1.04", "userIdentity": { "type": "IAMUser", "principalId": "AKIAIOSFODNN7EXAMPLE", "arn": "arn:aws:iam::123456789012:user/johndoe", "accountId": "123456789012", "accessKeyId": "AKIAI44QH8DHBEXAMPLE", "userName": "johndoe" }, "eventTime": "2018-07-30T22:14:06Z", "eventSource": "rds.amazonaws.com", "eventName": "CreateDBInstance", "awsRegion": "us-east-1", "sourceIPAddress": "192.0.2.0", "userAgent": "aws-cli/1.15.42 Python/3.6.1 Darwin/17.7.0 botocore/1.10.42", "requestParameters": { "enableCloudwatchLogsExports": [ "audit", "error", "general", "slowquery" ], "dBInstanceIdentifier": "test-instance", "engine": "mysql", "masterUsername": "myawsuser", "allocatedStorage": 20, "dBInstanceClass": "db.m1.small", "masterUserPassword": "****" }, "responseElements": { "dBInstanceArn": "arn:aws:rds:us-east-1:123456789012:db:test-instance", "storageEncrypted": false, "preferredBackupWindow": "10:27-10:57", "preferredMaintenanceWindow": "sat:05:47-sat:06:17", "backupRetentionPeriod": 1, "allocatedStorage": 20, "storageType": "standard", "engineVersion": "8.0.28", "dbInstancePort": 0, "optionGroupMemberships": [ { "status": "in-sync", "optionGroupName": "default:mysql-8-0" } ], "dBParameterGroups": [ { "dBParameterGroupName": "default.mysql8.0", "parameterApplyStatus": "in-sync" } ], "monitoringInterval": 0, "dBInstanceClass": "db.m1.small", "readReplicaDBInstanceIdentifiers": [], "dBSubnetGroup": { "dBSubnetGroupName": "default", "dBSubnetGroupDescription": "default", "subnets": [ { "subnetAvailabilityZone": {"name": "us-east-1b"}, "subnetIdentifier": "subnet-cbfff283", "subnetStatus": "Active" }, { "subnetAvailabilityZone": {"name": "us-east-1e"}, "subnetIdentifier": "subnet-d7c825e8", "subnetStatus": "Active" }, { "subnetAvailabilityZone": {"name": "us-east-1f"}, "subnetIdentifier": "subnet-6746046b", "subnetStatus": "Active" }, { "subnetAvailabilityZone": {"name": "us-east-1c"}, "subnetIdentifier": "subnet-bac383e0", "subnetStatus": "Active" }, { "subnetAvailabilityZone": {"name": "us-east-1d"}, "subnetIdentifier": "subnet-42599426", "subnetStatus": "Active" }, { "subnetAvailabilityZone": {"name": "us-east-1a"}, "subnetIdentifier": "subnet-da327bf6", "subnetStatus": "Active" } ], "vpcId": "vpc-136a4c6a", "subnetGroupStatus": "Complete" }, "masterUsername": "myawsuser", "multiAZ": false, "autoMinorVersionUpgrade": true, "engine": "mysql", "cACertificateIdentifier": "rds-ca-2015", "dbiResourceId": "db-ETDZIIXHEWY5N7GXVC4SH7H5IA", "dBSecurityGroups": [], "pendingModifiedValues": { "masterUserPassword": "****", "pendingCloudwatchLogsExports": { "logTypesToEnable": [ "audit", "error", "general", "slowquery" ] } }, "dBInstanceStatus": "creating", "publiclyAccessible": true, "domainMemberships": [], "copyTagsToSnapshot": false, "dBInstanceIdentifier": "test-instance", "licenseModel": "general-public-license", "iAMDatabaseAuthenticationEnabled": false, "performanceInsightsEnabled": false, "vpcSecurityGroups": [ { "status": "active", "vpcSecurityGroupId": "sg-f839b688" } ] }, "requestID": "daf2e3f5-96a3-4df7-a026-863f96db793e", "eventID": "797163d3-5726-441d-80a7-6eeb7464acd4", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

As shown in the userIdentity element in the preceding example, 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 AWS service.

For more information about the userIdentity, see the CloudTrail userIdentity element. For more information about CreateDBInstance and other Amazon RDS actions, see the Amazon RDS API Reference.