View a markdown version of this page

Mapping identity provider groups to Redshift roles - 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.

Mapping identity provider groups to Redshift roles

With trusted identity propagation for IAM, you can grant permissions to a directory group by creating an Redshift role with the same name as the group. When a member of the group signs in, the role is added to their session.

Prerequisites

Before you map groups to roles, make sure that you have the following:

  • Groups federation turned on – Groups are on for a session when the effective mode of the cluster or namespace is Federate users and groups, or when the database user was created or altered with FEDERATION WITH GROUPS. For more information, see Identity federation modes and Federating individual users with SQL.

  • AWS IAM Identity Center – An AWS IAM Identity Center instance with your users and groups provisioned from your identity provider (IdP), typically through SCIM. Each IdP user's user name in AWS IAM Identity Center must be the same as their database user name, for example alice@example.com. For more information, see Configure group-based access for trusted identity propagation in the IAM User Guide.

  • Network configuration for enhanced VPC routing – If enhanced VPC routing is turned on, your VPC must be able to reach AWS IAM Identity Center. For more information, see Using trusted identity propagation for IAM with enhanced VPC routing.

How it works

When a user signs in through trusted identity propagation for IAM with federated group support, Redshift does the following:

  1. Finds the IdP user in your account's default AWS IAM Identity Center instance by user name.

  2. Reads the IdP user's complete group membership.

  3. For each group, looks for an existing Redshift role with exactly the same name.

  4. Adds each matching role to the session.

Redshift never automatically creates a role from a group. A group with no matching role is ignored. To use a group, an administrator must explicitly create the role. For more information, see CREATE ROLE in the Amazon Redshift Database Developer Guide.

Note

If your cluster or workgroup has a registered AWS IAM Identity Center application, trusted identity propagation for IAM sign-ins use the same AWS IAM Identity Center users and roles as AWS IAM Identity Center sign-ins, instead of the name match described on this page. The roles are the namespaced roles for the IdP user's groups, such as awsidc:DataAnalysts. The identity federation mode and the system roles federation setting have no effect, and IAM trusted identity propagation sign-ins don't create roles, even when automatic role creation is turned on. If AWS IAM Identity Center has no user with the IdP user's user name, the sign-in fails.

Password sign-ins on these clusters and workgroups don't receive group roles. For more information, see Single sign-on with AWS IAM Identity Center.

Considerations

Consider the following when you map groups to roles:

  • Name matching – The role name must be the same as the group's display name in AWS IAM Identity Center, including case. Redshift stores unquoted names in lowercase, so use double quotation marks when the group name has uppercase letters or special characters. For example, CREATE ROLE "DataAnalysts"; matches the IdP group DataAnalysts, but CREATE ROLE DataAnalysts; creates the role dataanalysts, which doesn't match.

  • Group names that can't be mapped – A group name that contains a colon (:) is never mapped, except for the system role names described in Mapping system roles. A group name longer than 127 bytes is ignored because no role name can match it.

  • IAM role user sessions – Group roles apply only when the session runs as the IdP user. A session that runs as an IAM role user, such as IAMR:Analyst, or as the user named in a RedshiftDbUser session tag, doesn't receive group roles.

  • Password sign-ins – A database user who signs in with a password also receives group roles when groups are on for that user. Redshift finds the user with the same user name in the account's default AWS IAM Identity Center instance and adds the matching roles for that user's groups. Because the match is by name only, make sure that the database user and the AWS IAM Identity Center user represent the same IdP user. Superusers and users who hold a system role directly or through another role don't receive group roles when they sign in with a password, so they can still sign in when AWS IAM Identity Center is unavailable.

  • Session roles – Group roles are added to the session, not granted. They don't appear as persistent role grants in SVV_USER_GRANTS. To see the roles in a session, use PG_GET_SESSION_ROLES.

  • Incomplete group membership – If Redshift can't read the complete group membership, for example because AWS IAM Identity Center is unreachable or throttled, it doesn't add a partial set of roles, and the sign-in fails. On a resource without a registered AWS IAM Identity Center application, if the account's default AWS IAM Identity Center instance has no user whose user name matches the IdP user's identity, or the account has no AWS IAM Identity Center instance, the IdP user signs in without group roles. When groups are off, Redshift doesn't contact AWS IAM Identity Center during sign-in.

  • Membership changes – Group membership synchronization is eventually consistent. A connected session that received group roles at sign-in can gain or lose roles without reconnecting. Synchronization also removes group roles when groups are no longer on for the session, for example after you change the identity federation mode. If AWS IAM Identity Center can't be reached during synchronization, the session keeps its current roles. A session that signed in without group roles must reconnect before it can receive them.

  • Objects owned by a user – Views, materialized views, and stored procedures with SECURITY DEFINER use the owner's synchronized group roles even when the owner isn't connected. Changes to those roles are eventually consistent.

  • Combined permissions – An IdP user's access is the combination of permissions granted to their user, roles granted to their user, and roles from their groups. Redshift ignores the RedshiftDbRoles session tag when the session runs as the IdP user. The tag applies only when the session runs as another user, such as the IAM role user IAMR:Analyst.

Mapping system roles

IdP groups can't add Redshift system roles, such as sys:dba, unless you explicitly allow each system role. This prevents a group managed in your IdP from granting administrative permissions by accident. For more information, see Redshift system-defined roles in the Amazon Redshift Database Developer Guide.

To allow a system role, add it to the System roles federation setting for the account, cluster, or namespace. You can choose from these system roles:

  • sys:monitor

  • sys:operator

  • sys:dba

  • sys:secadmin

  • sys:superuser

A system role is added to a session only when all of the following are true:

  • Groups are on for the session.

  • The IdP user belongs to an IdP group with the system role's exact name in lowercase, for example sys:operator.

  • The system role is in the effective system roles federation list.

The system roles list is resolved independently from the identity federation mode. A cluster or namespace can use the account list, use its own list, or use an empty list so that no system role can be added on that resource.

A group can't add an ordinary role that has been granted a system role, directly or through another role, even if that system role is allowed. For example, if you granted sys:dba to the role DBAdmins, the group DBAdmins doesn't add the DBAdmins role. To let a group add sys:dba, allow sys:dba and name the group sys:dba.

Important

Treat membership in an IdP group named after a system role as administrative access to your data warehouse. Review who can manage those groups in your IdP before you allow a system role.

Examples

The following example creates a role for the IdP group DataAnalysts and grants it access to a table.

CREATE ROLE "DataAnalysts"; GRANT SELECT ON sales.orders TO ROLE "DataAnalysts";

When Alice, a member of the IdP group DataAnalysts, signs in with groups turned on, the session receives the DataAnalysts role and Alice can query sales.orders. The following query shows the roles in Alice's session. The role has the same name as the group, without a namespace prefix.

SELECT * FROM pg_get_session_roles() AS sess_roles(name name, roleid integer); name roleid ---------------------- DataAnalysts 106210

For how to attach an IAM Identity Center instance to your IAM identity provider so that groups resolve, see Configure group-based access for trusted identity propagation and Trusted identity propagation context keys and runtime claims for IAM federation in the IAM User Guide.