Auditing access and member cluster configuration
In a database cluster group for Aurora, each member cluster keeps its own parameter groups, users, and schema, and you decide how each one is configured. The group reads data on member clusters but doesn't validate it, so you run the checks on this page yourself. Keep records of access and changes, and audit the member clusters on a schedule.
For API calls on the group and its member clusters, see Monitoring Amazon Aurora API calls in AWS CloudTrail.
Auditing statements
Two audit logs record statements:
-
The routing layer audit log records statements and sign-ins at the routing endpoint, under the router user's name. Turn it on with the
auditvalue in the routing endpoint parameterenable_cloudwatch_logs_exports; see Creating, modifying, and deleting a database cluster group for Aurora. It doesn't record the statements of a pinned session, except the statement that sets the first pin; use the member cluster's audit log for pinned sessions. It delivers entries to Amazon CloudWatch Logs asynchronously, so they appear after a short delay. For a complete record of the statements that ran, for example for compliance, use the member cluster audit logs below. For its format, see Logs for database cluster groups for Aurora. -
Each member cluster's audit log records the statements that ran on it, both routed (under the member cluster user with the router user's name) and direct. Records name objects by their cluster names. Turn on Advanced Auditing (see Using Advanced Auditing with an Amazon Aurora MySQL DB cluster) with the same values for
server_audit_logging,server_audit_events,server_audit_incl_users, andserver_audit_excl_usersin every member cluster's DB cluster parameter group.
To tell routed statements from pinned-session or direct ones on a member cluster, classify sessions by their label on the member cluster: a session that the routing layer opened carries the _rds_connection_source connect attribute. Don't rely on the tid comment, which pinned-session, router-answered, and direct statements don't carry, and never on host. See Tracing a session or statement across the group.
On a schedule, compare each account's grants across every member cluster and against the router users, review who connects to each member cluster directly, and confirm that no application account sets router_cluster_pin (see SET router_cluster_pin) unless you intend it.
Recording mapping and router user changes
On Aurora MySQL, the routing layer audit log records each statement that changes a data mapping or a router user, with the router user who ran it. Statements that change a scaleout table or a routing function are in the DDL class. Statements that create, change, or drop a router user, or grant or revoke privileges, are in the DCL class. Data movement commands and default role changes are in no class, so only the QUERY event selects them. Statements in a pinned session aren't recorded.
Export the mappings before and after every mapping change, as described in Changing data mappings. Read dbclustergroup_sys.router_user_definition (see router_user_definition) before and after every router user change, and keep both copies. Make mapping changes through a reviewed path, such as a pipeline, and limit who holds dbclustergroup_metadata_admin.
Reviewing router users and their privileges
Review every router user and its privileges on a fixed schedule. You need the dbclustergroup_user_admin privilege.
-
At the routing endpoint, list each router user and its privileges.
SELECT username, host, authentication_method, account_locked, privileges, grantable_privileges FROM dbclustergroup_sys.router_user_definition; -
In the result, look for:
-
router users that hold
dbclustergroup_super_adminordbclustergroup_user_admin -
privileges in
grantable_privilegesthat a router user can pass on -
a host part of
%on an account that needs access from fewer hosts -
router users that you can't match to a person or an application
-
-
Read the statements that give one router user its privileges.
SHOW GRANTS FOR 'USER_NAME'@'HOST';
The table holds no password hashes, and you can't change it with INSERT, UPDATE, or DELETE. To change or remove a router user, see Maintaining router users.
The routing layer error log records most failed sign-ins at the routing endpoint, with the user name and client IP address, and each sign-in to a locked router user. These entries show whether a person or an application still uses a router user that you locked. See Connection and sign-in errors.
Detecting schema drift
Each member cluster keeps its own table definitions, and the routing layer routes by the data mappings without comparing them or checking the data. Run the following checks after every rollout, before every change to data mappings or scaleout tables, and on a schedule.
-
Member cluster against member cluster. On each member cluster, connected directly, read the table, column, index, and constraint definitions of each application database from
information_schemawith the following query. Compare them by role, not by name, because a scaleout member table can have a different cluster name on each member cluster. Name every constraint and index explicitly, because generated names include the cluster table name. -
Member cluster against data mappings. Read
dbclustergroup_sys.data_mappings(see data_mappings) at the routing endpoint, and confirm that every mapping row names a database or table that exists on its member cluster, and that each scaleout table's member tables exist. Also look for databases on a member cluster that no mapping routes to. -
Foreign keys. A foreign key holds only on its own member cluster. After a mapping change, a routing function switch, or a move, count child rows with no parent on each member cluster.
SELECT TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, CHARACTER_SET_NAME, COLLATION_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'CLUSTER_DB' ORDER BY TABLE_NAME, ORDINAL_POSITION; SELECT TABLE_NAME, INDEX_NAME, NON_UNIQUE, COLUMN_NAME, SEQ_IN_INDEX, IS_VISIBLE FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = 'CLUSTER_DB' ORDER BY TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX;
Auditing member cluster configuration
Check that every member cluster is configured the same way at the Amazon RDS level and in its engine settings. This audit compares configuration, not data. Collect every member cluster's configuration in the same run, so that a change between reads doesn't show as drift.
-
List the member clusters with
describe-db-cluster-groups. With routing enabled, cross-check the list withdbclustergroup_sys.member_cluster_mappings(see member_cluster_mappings) at the routing endpoint. For the parameters, seeDescribeDBClusterGroupsin the Amazon RDS API Reference.aws rds describe-db-cluster-groups --regionREGION--db-cluster-group-identifierGROUP_IDENTIFIER\ --query 'DBClusterGroups[0].DBClusterGroupMembers' -
For each member cluster, collect its cluster, its instances, and its parameter values with
describe-db-clusters,describe-db-instances, anddescribe-db-cluster-parameters, one file per member cluster. -
On each member cluster, connected directly, read the settings that change statement results and binary logging:
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM performance_schema.global_variables WHERE VARIABLE_NAME IN ('sql_mode', 'time_zone', 'character_set_server', 'collation_server', 'lower_case_table_names', 'transaction_isolation', 'explicit_defaults_for_timestamp', 'max_connections', 'log_bin', 'binlog_format') ORDER BY VARIABLE_NAME; -
Compare the member clusters, one column per member cluster: engine version, parameter values (not only parameter group names), backup and maintenance windows, deletion protection, and capacity settings, and for each instance the instance class, Performance Insights, and monitoring settings. Mark each row consistent, expected to differ, or drift. Check the settings that change results, and binary logging, first.
-
Fix one member cluster at a time: point it at the shared parameter group, or change a value in its group, and restart its writer if the parameter needs it. Then rerun step 2 for it.
-
At the routing endpoint, pin a session (see SET router_cluster_pin) to the fixed member cluster and run one routed read for each mapping on it.