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
Using Data API with trusted identity propagation
With trusted identity propagation, the Amazon Redshift Data API passes the identity of the user who signed in to Amazon Redshift. The Data API supports two sources of propagated identity:
-
AWS IAM Identity Center – Users sign in through IAM Identity Center and call the Data API from an identity-enhanced IAM role session. For more information, see Trusted identity propagation with IAM Identity Center.
-
IAM – Users sign in through a SAML or OIDC identity provider configured in IAM that has trusted identity propagation turned on. For more information, see Trusted identity propagation for IAM.
Trusted identity propagation with IAM Identity Center
As an Amazon Redshift account administrator, you can integrate your Amazon Redshift cluster or workgroup
with AWS IAM Identity Center, which helps manage your workforce access to Amazon Redshift with single sign-on.
For more information, see Setting up AWS IAM Identity Center integration with Amazon Redshift. The
Amazon Redshift Data API supports propagating IAM Identity Center user identities to an Amazon Redshift cluster or
workgroup, and to other services, such as, AWS Lake Formation, down the chain. You can set up
and query using the Data API by following the steps in Access AWS services programmatically using trusted identity
propagation
If you enable the simplified experience for trusted identity propagation in IAM Identity Center, the IAM role used by the IAM Identity Center user to call the Data API must also have permission to get Amazon Redshift database credentials:
-
For a provisioned cluster, grant
redshift:GetClusterCredentialsWithIAM. -
For an Amazon Redshift Serverless workgroup, grant
redshift-serverless:GetCredentials.
These permissions are required in addition to the permissions for the Data API operations that the role calls.
When you call the Data API using an IAM Identity Center user identity from an identity-enhanced
IAM role session, you can only access the resulting statement and statement result
using the same IAM Identity Center user. For example, the following AWS CLI command calls the
execute-statement operation to
run a SQL command with trusted identity propagation.
aws redshift-data execute-statement --sql "select current_user;" --cluster-idmycluster--databasedev
The following AWS CLI command calls the batch-execute-statement operation
to run two SQL commands.
aws redshift-data batch-execute-statement --sqls "select current_user;" "select current_date;" --cluster-idmycluster--databasedev
To access statements with cancel-statement,
describe-statement, get-statement-result, and
get-statement-result-v2 submitted by identity-enhanced IAM role
sessions, the IAM Identity Center user and IAM role must match the credentials used
to run execute-statement or batch-execute-statement. For
example, the following AWS CLI command gets the results of a SQL statement.
aws redshift-data get-statement-result --ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111
To list statements, a cluster-identifier or workgroup-name
parameter must be provided to ensure that the IAM Identity Center user only has access the Amazon Redshift IAM Identity Center
applications they are assigned to. For example, the following AWS CLI command lists
statements for a specific cluster.
aws redshift-data list-statements --cluster-identifiermycluster
You can also invoke the Data API operations that access database objects in a
cluster or workgroup using trusted identity propagation. This includes the
list-databases, list-schemas, list-tables,
and describe-table operations.
Auditing
API calls made by the IAM Identity Center user can be tracked in AWS CloudTrail. A onBehalfOf
section of the CloudTrail event shows the IAM Identity Center user id and the identity store ARN. The
following example shows a snippet of a CloudTrail event showing the onBehalfOf
section with the IAM Identity Center user ID of
a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 and the Identity store ARN of
arn:aws:identitystore::123456789012:identitystore/d-9067bc44d2.
{ "eventVersion":"1.10", "userIdentity":{ "type":"AssumedRole", ... }, "onBehalfOf":{ "userId":"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "identityStoreArn":"arn:aws:identitystore::123456789012:identitystore/d-9067bc44d2" } }, "eventTime":"2025-01-13T04:46:27Z", "eventSource":"redshift-data.amazonaws.com", "eventName":"ExecuteStatement", "awsRegion":"us-east-1" }
You can run the following SQL command to check the query submitted by the IAM
Identity Center user. In this example, the email registered in Identity Center is
username@example.com.
SELECT h.query_id, h.database_name, h.status, h.query_text, u.usename, h.start_time, h.end_time FROM sys_query_history h LEFT JOIN pg_user u ON h.user_id = u.usesysid where u.usename='awsidc:username@example.com' ORDER BY h.start_time DESC;
Trusted identity propagation for IAM
The Data API supports trusted identity propagation (TIP) for IAM. When an IdP user signs in through an IAM identity provider that has TIP turned on, the Data API passes the IdP user's identity to Amazon Redshift. You don't need an Amazon Redshift IAM Identity Center application or an identity-enhanced session. For more information, see Workforce identity with Trusted Identity Propagation for IAM.
To use it, call the Data API with the credentials of the IAM role that the
IdP user assumed, and don't specify --db-user or
--secret-arn.
aws redshift-data execute-statement \ --sql "select current_user;" \ --cluster-identifier mycluster \ --database dev
On a supported cluster, current_user returns the IdP user's Amazon Redshift
user, for example alice@example.com, depending on the identity
federation mode. For more information, see Before you start using trusted identity propagation for IAM.
For auditing information, see Auditing federated connections.
Isolating IdP users who share an IAM role
The Data API associates each statement and database session with the IAM role that created it. If your IdP users use the same IAM role, each user's propagated identity still determines their Amazon Redshift database user. Data API access to those statements and sessions, however, is scoped to the role, so by default users who share a role can see and reuse each other's statements and sessions.
If you want each IdP user to work only with their own statements and sessions, use the IAM role session to scope access:
-
Configure your identity provider to assign each user a unique role session name.
-
In the IAM policy that grants Data API access, restrict access to the statement owner and session owner. For more information about restricting access to the statement owner and session owner, see Configure an IAM policy that restricts access to SQL statement information to only the statement owner and Configure an IAM policy that restricts access to SQL results to only the session owner.