01 Run describe-trails command (OSX/Linux/UNIX) to list the names of all Amazon CloudTrail trails currently available within the selected AWS region:
aws cloudtrail describe-trails
--region us-east-1
--output table
--query 'trailList[*].Name'
02 The command output should return a table with the requested trail name(s):
---------------------------
| DescribeTrails |
+-------------------------+
| cc-global-cloud-trail |
+-------------------------+
03 Run again describe-trails command (OSX/Linux/UNIX) using the name of the trail returned at the previous step and custom query filters to get the name of the S3 bucket used to store the log files for the selected trail:
aws cloudtrail describe-trails
--region us-east-1
--trail-name-list cc-global-cloud-trail
--query 'trailList[*].S3BucketName'
04 The command output should return the name of the requested S3 bucket:
[
"cc-cloud-trail-logs"
]
05 Run list-objects command (OSX/Linux/UNIX) to list the names of all S3 objects available within the selected S3 bucket:
aws s3api list-objects
--region us-east-1
--bucket cc-cloud-trail-logs
--query 'Contents[].Key'
06 The command output should expose the name of each S3 object (i.e. CloudTrail log file) currently available in the selected S3 bucket:
[
"AWSLogs/123456789012/CloudTrail/us-east-1/2017/03/16/123456789012_
CloudTrail_us-east-1_20170316T0950Z_35ZWtvmCq5cuBxWyZ.json.gz",
"AWSLogs/123456789012/CloudTrail/us-east-1/2017/03/16/123456789012_
CloudTrail_us-east-1_20170316T0950Z_65ZWtvmCqOcuwXIo.json.gz",
"AWSLogs/123456789012/CloudTrail/us-east-1/2017/03/16/123456789012_
CloudTrail_us-east-1_20170316T0950Z_ntG0rPDvTVMKJdLe.json.gz",
"AWSLogs/123456789012/CloudTrail/us-east-1/2017/03/16/123456789012_
CloudTrail_us-east-1_20170316T0950Z_00euohtdKFqkNjPH.json.gz"
]
07 Run get-object command (OSX/Linux/UNIX) to get the right CloudTrail log file from the specified S3 bucket and download it to your machine:
aws s3api get-object
--region us-east-1
--bucket cc-cloud-trail-logs
--key AWSLogs/123456789012/CloudTrail/us-east-1/2017/03/16/123456789012_CloudTrail_us-east-1_20170316T0950Z_35ZWtvmCq5cuBxWyZ.json.gz 35ZWtvmCq5cuBxWyZ.json.gz
08 The command output should return the GET request metadata:
{
"AcceptRanges": "bytes",
"ContentType": "application/json",
"LastModified": "Sat, 16 Mar 2017 09:50:35 GMT",
"ContentLength": 791,
"ContentEncoding": "gzip",
"ETag": "\"cd5bfa01349b8713ec69e0e4cf6971ba\"",
"ServerSideEncryption": "AES256",
"Metadata": {}
}
09 Now extract and open the required CloudTrail log file, downloaded at the previous step, e.g. 35ZWtvmCq5cuBxWyZ.json.gz.
10 Once the log file is opened, search for the following attributes in order to identify the required log record:
- "eventSource":"rds.amazonaws.com" – for the name of the AWS service used to place the RI purchase request.
- "eventName":"PurchaseReservedDBInstancesOffering" – for the name of the AWS API action used to place the RI purchase request.
- "eventTime":"2017-03-16T09:50:14.352Z" – for the date when the RDS RI purchase request was placed.
11 Identify the right CloudTrail log record entry based on the attributes listed above and verify the "userIdentity" attribute value to determine the unwanted RDS RI purchase request origin and context.
12 Repeat steps no. 7 – 11 to verify the request origin and context for other unwanted RDS RI purchases available within the selected region.
13 Change the AWS region by updating the --region command parameter value and perform the entire process for other regions.