Tracking changes in your AMS Accelerate accounts
AWS Managed Services helps you track changes made by the AMS Accelerate Operations team and AMS Accelerate automation by providing a queryable interface using the Amazon Athena (Athena) console and AMS Accelerate log management.
Athena is an interactive query service you can use to analyze data in Amazon S3 by using standard Structured Query Language (SQL) (see SQL Reference for Amazon Athena). Athena is serverless, so there is no infrastructure to manage, and you pay only for the queries that you run. AMS Accelerate creates Athena tables with daily partitions over CloudTrail logs, and provides queries on your primary AWS Region and within the ams-change-record workgroup. You can choose any of the default queries and run them as needed. To learn more about Athena workgroups, see How Workgroups Work.
Note
Only Accelerate can query CloudTrail events for your Accelerate account using Athena when Accelerate is integrated with your CloudTrail Organization trail, unless your Organization administrator deployed an IAM Role for using Athena to query and analyze CloudTrail events in your account, during onboarding.
Using change record, you can easily answer questions like:
Who (AMS Accelerate Systems or AMS Accelerate Operators) has accessed your account
What changes have been made by AMS Accelerate in your account
When did AMS Accelerate perform changes in your account
Where to go to view changes made in your account
Why AMS Accelerate needed to make the changes in your account
How to modify queries to get answers to all those questions for any non-AMS changes too
Viewing your change records
To use Athena queries, sign in to the AWS Management console and navigate to the Athena console in your primary AWS Region.
Note
If you see the Amazon Athena Get Started page while performing any of the steps, click Get Started. This might appear for you even if your Change Record infrastructure is already in place.
Choose Workgroup from the upper navigation panel in the Athena console.
Choose the ams-change-record workgroup, and then click Switch Workgroup.
Choose ams-change-record-database from the Database Combo box. The ams-change-record-database includes the ams-change-record-table table.
Choose Saved Queries from the upper navigation panel.
The Saved Queries window shows a list of queries that AMS Accelerate provides, which you can run. Choose the query you want to run from the Saved Queries list. For example, ams_session_accesses_v1 query.
For the full list of preset AMS Accelerate queries, see Default queries.
Adjust the datetime filter in the query editor box as needed; by default, the query only checks changes from the last day.
Choose Run query.
Default queries
AMS Accelerate provides several default queries you can use within the Athena console; they are listed in the following table.
Note
All queries accept datetime range as an optional filter; all the queries run over the last 24 hours, by default. For expected input, see the following subsection, Modifying the datetime filter in queries.
Parameter inputs that you can or need to change are shown in the query as
<PARAMETER_NAME>
with angular braces. Replace the placeholder and the angular braces with your parameter value.All filters are optional. In the queries, some optional filters are commented out with a double dash (--) at the start of the line. All queries will run without them, with default parameters. If you want to specify parameter values for these optional filters, remove the double dash (--) at the start of the line and replace the parameter as you want.
All queries return
IAM PincipalId
andIAM SessionId
in the outputsThe calculated cost for running a query depends on how many CloudTrail logs are generated for the account. To calculate the cost, use the AWS Athena Pricing Calculator
.
Purpose/Description | Inputs | Outputs |
---|---|---|
Query name:
| ||
Tracking AMS Accelerate access sessions Provides information about a specific AMS Accelerate access session. The query accepts the IAM Principal ID as an optional filter and returns event time, business need for accessing the account, requester, and so on. You can filter on a specific IAM Principal ID by uncommenting the line and replacing the placeholder
You can also list non-AMS access sessions by removing the useragent filter line in the WHERE clause of the query. |
(Optional) |
|
Query name:
| ||
Track all mutating actions done by AMS Accelerate Returns all write actions done on the account using that AMS Accelerate role filter. You can also track mutating actions done by non-AMS roles by removing the useridentity.arn filter lines from the WHERE clause of the query. |
(Optional) Only datetime range. See Modifying the datetime filter in queries. |
|
Query name:
| ||
Track instance accesses by AMS Accelerate Returns a list of AMS Accelerate instance accesses; every record includes event
time, event Region, instance ID, IAM Principal ID, IAM Session ID, SSM Session
ID. You can use the IAM Principal ID to get more details on the business need for
accessing the instance by using the Users can also list non-AMS instance accesses by removing the useridentity filter line in the WHERE clause of the query. |
Only |
|
Query name:
| ||
Track permission (escalation) events for AMS and non-AMS users Provides a list of events that can directly or potentially lead to a privilege escalation. The query accepts ActionedBy as an optional filter and returns EventName, EventId, EventTime, and so forth. All fields associated with the event are also returned. Fields are blank if not applicable for that event. The ActionedBy filter is disabled, by default; to enable it, remove "-- " from that line. By default, the ActionedBy filter is disabled (it will show privilege escalation events from all users). To show
events for a particular user or role, remove the double dash (--) from the useridentity filter
line in the WHERE clause and replace the placeholder |
(Optional) (Optional) |
|
Query name:
| ||
Track write events for specific resources AMS or non-AMS Provides a list of events done on a specific resource. The query accepts resource ID as part of
the filters (replace placeholder |
(Required) (Optional) |
|
Query name:
| ||
Track write actions performed by AMS Accelerate during specific session Provides a list of events done on a specific session. The query accepts IAM Principal ID as part
of the filters (replace the placeholder |
(Required) (Optional) |
|
Query name:
| ||
Track IAM Principal/Session IDs for a specific requester. The query accepts "requester" (replace the placeholder |
(Required) (Optional) |
|
Modifying the datetime filter in queries
All queries accept datetime range as an optional filter. All the queries run over the last one day by default.
The format used for the datetime field is yyyy/MM/dd (for example: 2021/01/01). Remember that it only stores the date and not the entire timestamp. For the entire timestamp, use the field eventime, which stores the timestamp in the ISO 8601 format yyyy-MM-ddTHH:mm:ssZ (for example: 2021-01-01T23:59:59Z). However, since the table is partitioned on the datetime field, you’ll need to pass in both the datetime and eventtime filter to the query. See the following examples.
Note
To see all the accepted ways you can modify the range, see the latest Presto function documentation based on the Athena engine version currently used for the Date and Time Functions and Operators to see all the accepted ways you can modify the range.
Date Level: Last 1 day or last 24 hours (Default) example: If the CURRENT_DATE='2021/01/01' , the filter will subtract one day from the current date and format it as datetime > '2020/12/31'
datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d')
Date Level: Last 2 months example:
datetime > date_format(date_add('month', - 2, CURRENT_DATE), '%Y/%m/%d')
Date Level: Between 2 dates example:
datetime > '2021/01/01' AND datetime < '2021/01/10'
Timestamp Level: Last 12 hours example:
Partition data scanned to last 1 day and then filter all events within the last 12 hours
datetime > date_format(date_add('day', - 1, CURRENT_DATE), '%Y/%m/%d') AND eventtime > date_format(date_add('hour', - 12, CURRENT_TIMESTAMP), '%Y-%m-%dT%H:%i:%sZ')
Timestamp Level: Between 2 timestamps example:
Get events between Jan 1, 2021 12:00PM and Jan 10, 2021 3:00PM.
datetime > '2021/01/01' AND datetime < '2021/01/10' AND eventtime > '2021-01-01T12:00:00Z' AND eventtime < '2021-01-10T15:00:00Z'
Change record permissions
The following permissions are needed to run change record queries:
Athena
athena:GetWorkGroup
athena:StartQueryExecution
athena:ListDataCatalogs
athena:GetQueryExecution
athena:GetQueryResults
athena:BatchGetNamedQuery
athena:ListWorkGroups
athena:UpdateWorkGroup
athena:GetNamedQuery
athena:ListQueryExecutions
athena:ListNamedQueries
AWS KMS
kms:Decrypt
AWS KMS key ID of AMSCloudTrailLogManagement, or your AWS KMS key ID(s), if Accelerate is using your CloudTrail trail events Amazon S3 bucket data store using SSE-KMS encryption.
AWS Glue
glue:GetDatabase
glue:GetTables
glue:GetDatabases
glue:GetTable
Amazon S3 read access
Amazon S3 bucket CloudTrail datastore: ams-a
AccountId
-cloudtrail-primary region
, or your Amazon S3 bucket name, CloudTrail trail events Amazon S3 bucket data store.
Amazon S3 write access
Athena events query results Amazon S3 bucket: ams-a
AccountId
athena-results-primary region