

# Identity propagation with Athena workgroups

In Amazon Athena, when a caller's credentials carry an identity context, an IAM workgroup that runs Athena SQL uses it to propagate the caller's identity to downstream Amazon services. You don't change a workgroup setting or the client to use this.

Athena supports identity propagation for IAM workgroups in Amazon Commercial Regions, China Regions, and Amazon GovCloud (US) Region.

## About the identity context
<a name="security-identity-propagation-workgroups-context"></a>

An identity context is information bound to the caller's Amazon credentials that identifies the user from their identity source, so that Amazon services can authorize and log the request on the user rather than only on the IAM role.

An IAM workgroup can carry an identity context from either of the following sources:
+ Trusted identity propagation with IAM Identity Center – The context identifies the IAM Identity Center user and their groups, carried in identity-enhanced credentials from EMR Studio, SageMaker Unified Studio, or the Athena JDBC and ODBC drivers. For an overview, see [Trusted identity propagation overview](https://docs.amazonaws.cn/singlesignon/latest/userguide/trustedidentitypropagation-overview.html) in the *Amazon IAM Identity Center User Guide*.
+ Trusted identity propagation with IAM federation – In IAM federation, when a user or workload federates through your OpenID Connect (OIDC) or SAML identity provider, IAM attaches the identity context to the federated role session from the claims you map, and the caller can't change it for the session. The context carries condition keys that identify the user, such as `aws:OriginIdentity/Subject`, and optional identity provider claims under `aws:TransactionContext/IdentityProvider/`; you can use these keys in IAM policies, and Amazon CloudTrail can record them for services that support it. For more information, see [Trusted identity propagation for IAM federation](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_providers_tip_federation.html) in the *IAM User Guide*.

Downstream Amazon services use the identity context to authorize and log requests on the user rather than only on the IAM role. For either source, the context is available as condition keys in IAM policies, and Amazon CloudTrail can record the user identity for services that support it. When the identity context comes from IAM Identity Center, Lake Formation can also grant access directly to IAM Identity Center users and groups.

For more information about each identity source, see [Trusted identity propagation overview](https://docs.amazonaws.cn/singlesignon/latest/userguide/trustedidentitypropagation-overview.html) and [IAM Identity Center information in CloudTrail](https://docs.amazonaws.cn/singlesignon/latest/userguide/sso-info-in-cloudtrail.html) in the *Amazon IAM Identity Center User Guide* for IAM Identity Center, and [Trusted identity propagation for IAM federation](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_providers_tip_federation.html) and [Amazon services that support TIP](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_roles_providers_tip_services.html) in the *IAM User Guide* for IAM federation.

## How Athena IAM workgroups use the identity context
<a name="security-identity-propagation-workgroups-how"></a>

When a user runs a query in an IAM workgroup, the identity flows through Athena as follows:

1. A client or driver sends the user's credentials, which carry the identity context (identity-enhanced credentials from IAM Identity Center, or federated session credentials from IAM federation), to Athena.

1. Athena authorizes the query on the caller's IAM role permissions and runs it in the IAM workgroup.

1. For the downstream access that the query needs, Athena uses the caller's forward access session (FAS) credentials to reach Amazon S3 (data reads and query-result writes), the Amazon Glue Data Catalog, and Lake Formation. The workgroup-level option to store query results in identity-based Amazon S3 locations governed by Amazon S3 Access Grants applies to IAM Identity Center enabled workgroups.

1. When the identity context comes from IAM Identity Center, Lake Formation can authorize access based on the IAM Identity Center user or group. This requires Lake Formation to be set up for IAM Identity Center identities; see [Integrating IAM Identity Center](https://docs.amazonaws.cn/lake-formation/latest/dg/identity-center-integration.html) in the *Amazon Lake Formation Developer Guide*.

Identity propagation applies to Athena SQL workgroups. Athena for Spark workgroups don't accept propagated identities.

With IAM workgroups, you can use identities from an IAM Identity Center instance regardless of whether you turn on the simplified experience for trusted identity propagation.

Athena also offers IAM Identity Center enabled workgroups, which accept IAM Identity Center users only and use an application-based setup. For more information, see [Use IAM Identity Center enabled Athena workgroups](workgroups-identity-center.md).