View a markdown version of this page

Auditing federated connections - Amazon Redshift

Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the blog post that was published on June 30, 2025.

Auditing federated connections

With trusted identity propagation for IAM, Redshift records the IdP user behind each federated connection, in every identity federation mode, including Default. You don't need to change any setting to start auditing.

Connection logs

Redshift records both identities of a federated session in STL_CONNECTION_LOG and SYS_CONNECTION_LOG. One identity is the database identity that the session runs as. The other is recorded in the associated_identity column.

Session runs asUser nameassociated_identity
The IdP useralice@example.comIAMR:Analyst
The IAM role userIAMR:Analystalice@example.com
The IdP user, on a cluster with an IAM Identity Center applicationnamespace:alice@example.comEmpty
Password or plain IAM sign-inThe userEmpty

The associated_identity column is for auditing only. It never grants permissions.

Sessions that sign in with a trusted identity propagation credential show IAM TIP in the authmethod column of STL_CONNECTION_LOG and the auth_method column of SYS_CONNECTION_LOG. Sessions that sign in as an IAM role user show IAM AssumeUser, even when associated_identity names the IdP user.

Only superusers can see all rows in STL_CONNECTION_LOG and SYS_CONNECTION_LOG.

Example: Find every connection for an IdP user

SELECT recordtime, username, authmethod, associated_identity FROM stl_connection_log WHERE username = 'alice@example.com' OR username LIKE '%:alice@example.com' OR associated_identity = 'alice@example.com' ORDER BY recordtime DESC;

Example: Find refused federated sign-ins

SELECT * FROM sys_connection_log WHERE event = 'authentication failure' AND auth_method = 'IAM TIP' ORDER BY record_time DESC;

Session roles

To see which roles a session received from IdP groups, run pg_get_session_roles() in the session.

SELECT * FROM pg_get_session_roles() AS t(rolname name, rolid int);

Query and data loading activity

Queries, COPY, and UNLOAD run by an IdP user who signs in as themselves are recorded under the IdP user's database user in SYS_QUERY_HISTORY, STL_QUERY, STL_LOAD_COMMITS, and STL_UNLOAD_LOG, including queries that run on concurrency scaling clusters.

AWS CloudTrail

The iam_auth_guid column of SYS_CONNECTION_LOG (iamauthguid in STL_CONNECTION_LOG) is the request ID of the GetClusterCredentialsWithIAM or GetCredentials call that issued the credential. To trace a connection back to its credential request, find the CloudTrail event with the same request ID.

Example: Find the credential request behind a connection

  1. Find the connection and its iam_auth_guid.

    SELECT record_time, user_name, auth_method, iam_auth_guid FROM sys_connection_log WHERE event = 'authenticated' AND user_name = 'alice@example.com' ORDER BY record_time DESC;
    record_time | user_name | auth_method | iam_auth_guid ---------------------------+-------------------+-------------+-------------------------------------- 2026-11-19 22:54:47.140102 | alice@example.com | IAM TIP | 0f96569c-3c73-4886-82ef-68d87cd6bb8d
  2. Find the CloudTrail event whose requestID matches. Use a time window that starts a few minutes before record_time.

    aws cloudtrail lookup-events --region us-east-1 \ --lookup-attributes AttributeKey=EventName,AttributeValue=GetClusterCredentialsWithIAM \ --start-time 2026-11-19T22:50:00Z --end-time 2026-11-19T23:00:00Z \ --query "Events[?contains(CloudTrailEvent, '0f96569c-3c73-4886-82ef-68d87cd6bb8d')].CloudTrailEvent" \ --output text

For Amazon Redshift Serverless, use GetCredentials as the event name.

The matching event contains:

{ "eventTime": "2026-11-19T22:54:46Z", "eventSource": "redshift.amazonaws.com", "eventName": "GetClusterCredentialsWithIAM", "requestID": "0f96569c-3c73-4886-82ef-68d87cd6bb8d" }

Errors

Statements that fail because Redshift couldn't attach the IdP user's identity to a downstream request are recorded in STL_ERROR. Sign-ins that are refused after the credential is accepted, for example because the IdP user can't be mapped to a database user, are recorded in SYS_CONNECTION_LOG with the event authentication failure. A sign-in refused because the credential itself is invalid or expired isn't recorded there.