

 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 ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/) 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
<a name="redshift-iam-access-control-tip-audit-connections"></a>

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 as | User name | `associated_identity` | 
| --- | --- | --- | 
| The IdP user | alice@example.com | IAMR:Analyst | 
| The IAM role user | IAMR:Analyst | alice@example.com | 
| The IdP user, on a cluster with an IAM Identity Center application | {{namespace}}:alice@example.com | Empty | 
| Password or plain IAM sign-in | The user | Empty | 

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**

```sql
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**

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

## Session roles
<a name="redshift-iam-access-control-tip-audit-session-roles"></a>

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

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

## Query and data loading activity
<a name="redshift-iam-access-control-tip-audit-query-activity"></a>

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
<a name="redshift-iam-access-control-tip-audit-cloudtrail"></a>

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`.

   ```sql
   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
   ```

1. Find the CloudTrail event whose `requestID` matches. Use a time window that starts a few minutes before `record_time`.

   ```bash
   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:

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

## Errors
<a name="redshift-iam-access-control-tip-audit-errors"></a>

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.

## Related topics
<a name="redshift-iam-access-control-tip-audit-related-topics"></a>
+ [Database audit logging](db-auditing.md)
+ [Logging with CloudTrail](logging-with-cloudtrail.md)
+ [STL\_CONNECTION\_LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_CONNECTION_LOG.html)
+ [SYS\_CONNECTION\_LOG](https://docs.aws.amazon.com/redshift/latest/dg/SYS_CONNECTION_LOG.html)
+ [Logging trusted identity propagation activity with AWS CloudTrail](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_tip_cloudtrail.html) in the *IAM User Guide*
+ [IAM Identity Center information in AWS CloudTrail](https://docs.aws.amazon.com/singlesignon/latest/userguide/sso-info-in-cloudtrail.html) in the *AWS IAM Identity Center User Guide*